Drush: commands/core/drupal/update.inc Source File

  1. 7.x doxygen/html/update_8inc_source.html
  2. master doxygen/html/update_8inc_source.html
Go to the documentation of this file.
1 <?php
2 /**
3  * @file
4  * Update.php for provisioned sites.
5  * This file is a derivative of the standard drupal update.php,
6  * which has been modified to allow being run from the command
7  * line.
8  */
9 
11 
12 /**
13  * Drupal's update.inc has functions that are in previous update_X.inc files
14  * for example, update_check_incompatibility() which can prove useful when
15  * enabling modules.
16  */
17 require_once DRUSH_DRUPAL_CORE . '/includes/update.inc';
18 
19 use Drupal\Core\Utility\Error;
20 use Drupal\Core\Entity\EntityStorageException;
21 /**
22  * Perform one update and store the results which will later be displayed on
23  * the finished page.
24  *
25  * An update function can force the current and all later updates for this
26  * module to abort by returning a $ret array with an element like:
27  * $ret['#abort'] = array('success' => FALSE, 'query' => 'What went wrong');
28  * The schema version will not be updated in this case, and all the
29  * aborted updates will continue to appear on update.php as updates that
30  * have not yet been run.
31  *
32  * @param $module
33  * The module whose update will be run.
34  * @param $number
35  * The update number to run.
36  * @param $context
37  * The batch context array
38  */
39 function drush_update_do_one($module, $number, $dependency_map, &$context) {
40  $function = $module . '_update_' . $number;
41 
42  // If this update was aborted in a previous step, or has a dependency that
43  // was aborted in a previous step, go no further.
44  if (!empty($context['results']['#abort']) && array_intersect($context['results']['#abort'], array_merge($dependency_map, array($function)))) {
45  return;
46  }
47 
48  $context['log'] = FALSE;
49 
50  \Drupal::moduleHandler()->loadInclude($module, 'install');
51 
52  $ret = array();
53  if (function_exists($function)) {
54  try {
55  if ($context['log']) {
56  Database::startLog($function);
57  }
58 
59  drush_log("Executing " . $function);
60  $ret['results']['query'] = $function($context['sandbox']);
61  $ret['results']['success'] = TRUE;
62  }
63  // @TODO We may want to do different error handling for different exception
64  // types, but for now we'll just print the message.
65  catch (Exception $e) {
66  $ret['#abort'] = array('success' => FALSE, 'query' => $e->getMessage());
67  drush_set_error('DRUPAL_EXCEPTION', $e->getMessage());
68  }
69 
70  if ($context['log']) {
71  $ret['queries'] = Database::getLog($function);
72  }
73  }
74  else {
75  $ret['#abort'] = array('success' => FALSE);
76  drush_set_error('DRUSH_UPDATE_FUNCTION_NOT_FOUND', dt('Update function @function not found', array('@function' => $function)));
77  }
78 
79  if (isset($context['sandbox']['#finished'])) {
80  $context['finished'] = $context['sandbox']['#finished'];
81  unset($context['sandbox']['#finished']);
82  }
83 
84  if (!isset($context['results'][$module])) {
85  $context['results'][$module] = array();
86  }
87  if (!isset($context['results'][$module][$number])) {
88  $context['results'][$module][$number] = array();
89  }
90  $context['results'][$module][$number] = array_merge($context['results'][$module][$number], $ret);
91 
92  if (!empty($ret['#abort'])) {
93  // Record this function in the list of updates that were aborted.
94  $context['results']['#abort'][] = $function;
95  }
96 
97  // Record the schema update if it was completed successfully.
98  if ($context['finished'] == 1 && empty($ret['#abort'])) {
99  drupal_set_installed_schema_version($module, $number);
100  }
101 
102  $context['message'] = 'Performing ' . $function;
103 }
104 
105 function update_main() {
106  // In D8, we expect to be in full bootstrap.
108 
109  require_once DRUPAL_ROOT . '/core/includes/install.inc';
110  require_once DRUPAL_ROOT . '/core/includes/update.inc';
111  drupal_load_updates();
112  update_fix_compatibility();
113 
114  // Pending hook_update_N() implementations.
115  $pending = update_get_update_list();
116 
117  // Pending hook_post_update_X() implementations.
118  $post_updates = \Drupal::service('update.post_update_registry')->getPendingUpdateInformation();
119 
120  $start = array();
121 
122  $change_summary = [];
123  if (drush_get_option('entity-updates', FALSE)) {
124  $change_summary = \Drupal::entityDefinitionUpdateManager()->getChangeSummary();
125  }
126 
127  // Print a list of pending updates for this module and get confirmation.
128  if (count($pending) || count($change_summary) || count($post_updates)) {
129  drush_print(dt('The following updates are pending:'));
130  drush_print();
131 
132  foreach ($change_summary as $entity_type_id => $changes) {
133  drush_print($entity_type_id . ' entity type : ');
134  foreach ($changes as $change) {
135  drush_print(strip_tags($change), 2);
136  }
137  }
138 
139  foreach (array('update', 'post_update') as $update_type) {
140  $updates = $update_type == 'update' ? $pending : $post_updates;
141  foreach ($updates as $module => $updates) {
142  if (isset($updates['start'])) {
143  drush_print($module . ' module : ');
144  if (!empty($updates['pending'])) {
145  $start += [$module => array()];
146 
147  $start[$module] = array_merge($start[$module], $updates['pending']);
148  foreach ($updates['pending'] as $update) {
149  drush_print(strip_tags($update), 2);
150  }
151  }
152  drush_print();
153  }
154  }
155  }
156 
157  if (!drush_confirm(dt('Do you wish to run all pending updates?'))) {
158  return drush_user_abort();
159  }
160 
161  drush_update_batch($start);
162  }
163  else {
164  drush_log(dt("No database updates required"), LogLevel::SUCCESS);
165  }
166 
167  return count($pending) + count($change_summary) + count($post_updates);
168 }
169 
170 function _update_batch_command($id) {
171  // In D8, we expect to be in full bootstrap.
173 
174  drush_batch_command($id);
175 }
176 
177 /**
178  * Start the database update batch process.
179  */
180 function drush_update_batch() {
181  $start = drush_get_update_list();
182  // Resolve any update dependencies to determine the actual updates that will
183  // be run and the order they will be run in.
184  $updates = update_resolve_dependencies($start);
185 
186  // Store the dependencies for each update function in an array which the
187  // batch API can pass in to the batch operation each time it is called. (We
188  // do not store the entire update dependency array here because it is
189  // potentially very large.)
190  $dependency_map = array();
191  foreach ($updates as $function => $update) {
192  $dependency_map[$function] = !empty($update['reverse_paths']) ? array_keys($update['reverse_paths']) : array();
193  }
194 
195  $operations = array();
196 
197  foreach ($updates as $update) {
198  if ($update['allowed']) {
199  // Set the installed version of each module so updates will start at the
200  // correct place. (The updates are already sorted, so we can simply base
201  // this on the first one we come across in the above foreach loop.)
202  if (isset($start[$update['module']])) {
203  drupal_set_installed_schema_version($update['module'], $update['number'] - 1);
204  unset($start[$update['module']]);
205  }
206  // Add this update function to the batch.
207  $function = $update['module'] . '_update_' . $update['number'];
208  $operations[] = array('drush_update_do_one', array($update['module'], $update['number'], $dependency_map[$function]));
209  }
210  }
211 
212  // Apply post update hooks.
213  $post_updates = \Drupal::service('update.post_update_registry')->getPendingUpdateFunctions();
214  if ($post_updates) {
215  $operations[] = ['drush_drupal_cache_clear_all', []];
216  foreach ($post_updates as $function) {
217  $operations[] = ['update_invoke_post_update', [$function]];
218  }
219  }
220 
221  // Lastly, perform entity definition updates, which will update storage
222  // schema if needed. If module update functions need to work with specific
223  // entity schema they should call the entity update service for the specific
224  // update themselves.
225  // @see \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface::applyEntityUpdate()
226  // @see \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface::applyFieldUpdate()
227  if (drush_get_option('entity-updates', FALSE) && \Drupal::entityDefinitionUpdateManager()->needsUpdates()) {
228  $operations[] = array('drush_update_entity_definitions', array());
229  }
230 
231  $batch['operations'] = $operations;
232  $batch += array(
233  'title' => 'Updating',
234  'init_message' => 'Starting updates',
235  'error_message' => 'An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference.',
236  'finished' => 'drush_update_finished',
237  'file' => 'includes/update.inc',
238  );
239  batch_set($batch);
240  \Drupal::service('state')->set('system.maintenance_mode', TRUE);
241  drush_backend_batch_process('updatedb-batch-process');
242  \Drupal::service('state')->set('system.maintenance_mode', FALSE);
243 }
244 
245 /**
246  * Apply entity schema updates.
247  */
248 function drush_update_entity_definitions(&$context) {
249  try {
250  \Drupal::entityDefinitionUpdateManager()->applyUpdates();
251  }
252  catch (EntityStorageException $e) {
253  watchdog_exception('update', $e);
254  $variables = Error::decodeException($e);
255  unset($variables['backtrace']);
256  // The exception message is run through
257  // \Drupal\Component\Utility\SafeMarkup::checkPlain() by
258  // \Drupal\Core\Utility\Error::decodeException().
259  $ret['#abort'] = array('success' => FALSE, 'query' => t('%type: !message in %function (line %line of %file).', $variables));
260  $context['results']['core']['update_entity_definitions'] = $ret;
261  $context['results']['#abort'][] = 'update_entity_definitions';
262  }
263 }
264 
265 // Copy of protected \Drupal\system\Controller\DbUpdateController::getModuleUpdates.
266 function drush_get_update_list() {
267  $return = array();
268  $updates = update_get_update_list();
269  foreach ($updates as $module => $update) {
270  $return[$module] = $update['start'];
271  }
272 
273  return $return;
274 }
275 
276 /**
277  * Process and display any returned update output.
278  *
279  * @see \Drupal\system\Controller\DbUpdateController::batchFinished()
280  * @see \Drupal\system\Controller\DbUpdateController::results()
281  */
282 function drush_update_finished($success, $results, $operations) {
283 
284  if (!drush_get_option('cache-clear', TRUE)) {
285  drush_log(dt("Skipping cache-clear operation due to --cache-clear=0 option."), LogLevel::WARNING);
286  }
287  else {
288  drupal_flush_all_caches();
289  }
290 
291  foreach ($results as $module => $updates) {
292  if ($module != '#abort') {
293  foreach ($updates as $number => $queries) {
294  foreach ($queries as $query) {
295  // If there is no message for this update, don't show anything.
296  if (empty($query['query'])) {
297  continue;
298  }
299 
300  if ($query['success']) {
301  drush_log(strip_tags($query['query']));
302  }
303  else {
304  drush_set_error(dt('Failed: ') . strip_tags($query['query']));
305  }
306  }
307  }
308  }
309  }
310 }
311 
312 /**
313  * Return a 2 item array with
314  * - an array where each item is a 3 item associative array describing a pending update.
315  * - an array listing the first update to run, keyed by module.
316  */
317 function updatedb_status() {
318  $pending = update_get_update_list();
319 
320  $return = array();
321  // Ensure system module's updates run first.
322  $start['system'] = array();
323 
324  foreach (\Drupal::entityDefinitionUpdateManager()->getChangeSummary() as $entity_type_id => $changes) {
325  foreach ($changes as $change) {
326  $return[] = array(
327  'module' => dt('@type entity type', array('@type' => $entity_type_id)), 'update_id' => '', 'description' => strip_tags($change));
328  }
329  }
330 
331  // Print a list of pending updates for this module and get confirmation.
332  foreach ($pending as $module => $updates) {
333  if (isset($updates['start'])) {
334  foreach ($updates['pending'] as $update_id => $description) {
335  // Strip cruft from front.
336  $description = str_replace($update_id . ' - ', '', $description);
337  $return[] = array('module' => ucfirst($module), 'update_id' => $update_id, 'description' => $description);
338  }
339  if (isset($updates['start'])) {
340  $start[$module] = $updates['start'];
341  }
342  }
343  }
344 
345  return array($return, $start);
346 }
347 
348 /**
349  * Apply pending entity schema updates.
350  */
352  $change_summary = \Drupal::entityDefinitionUpdateManager()->getChangeSummary();
353  if (!empty($change_summary)) {
354  drush_print(dt('The following updates are pending:'));
355  drush_print();
356 
357  foreach ($change_summary as $entity_type_id => $changes) {
358  drush_print($entity_type_id . ' entity type : ');
359  foreach ($changes as $change) {
360  drush_print(strip_tags($change), 2);
361  }
362  }
363 
364  if (!drush_confirm(dt('Do you wish to run all pending updates?'))) {
365  return drush_user_abort();
366  }
367 
368  $operations[] = array('drush_update_entity_definitions', array());
369 
370 
371  $batch['operations'] = $operations;
372  $batch += array(
373  'title' => 'Updating',
374  'init_message' => 'Starting updates',
375  'error_message' => 'An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference.',
376  'finished' => 'drush_update_finished',
377  'file' => 'includes/update.inc',
378  );
379  batch_set($batch);
380  \Drupal::service('state')->set('system.maintenance_mode', TRUE);
381  drush_backend_batch_process('updatedb-batch-process');
382  \Drupal::service('state')->set('system.maintenance_mode', FALSE);
383  }
384  else {
385  drush_log(dt("No entity schema updates required"), LogLevel::SUCCESS);
386  }
387 }

File

doxygen/html/update_8inc_source.html
View source
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Drush: commands/core/drupal/update.inc Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Drush
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1.2 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_afac61274991793aa7e9133a8f4f291e.html">commands</a></li><li class="navelem"><a class="el" href="dir_5762b63965e3a68a35f77c23b4dd4668.html">core</a></li><li class="navelem"><a class="el" href="dir_124c2f0cfa86b0affb712ae9b365039b.html">drupal</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">update.inc</div>  </div>
</div><!--header-->
<div class="contents">
<a href="update_8inc.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&lt;?php<span class="comment"></span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> * @file</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> *   Update.php for provisioned sites.</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> *   This file is a derivative of the standard drupal update.php,</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> *   which has been modified to allow being run from the command</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment"> *   line.</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;</div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;use <a class="code" href="classDrush_1_1Log_1_1LogLevel.html">Drush\Log\LogLevel</a>;</div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment"> * Drupal&#39;s update.inc has functions that are in previous update_X.inc files</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment"> * for example, update_check_incompatibility() which can prove useful when</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment"> * enabling modules.</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;require_once DRUSH_DRUPAL_CORE . <span class="stringliteral">&#39;/includes/update.inc&#39;</span>;</div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;use Drupal\Core\Utility\Error;</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;use Drupal\Core\Entity\EntityStorageException;<span class="comment"></span></div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="comment"> * Perform one update and store the results which will later be displayed on</span></div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="comment"> * the finished page.</span></div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="comment"> * An update function can force the current and all later updates for this</span></div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="comment"> * module to abort by returning a $ret array with an element like:</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="comment"> * $ret[&#39;#abort&#39;] = array(&#39;success&#39; =&gt; FALSE, &#39;query&#39; =&gt; &#39;What went wrong&#39;);</span></div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="comment"> * The schema version will not be updated in this case, and all the</span></div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="comment"> * aborted updates will continue to appear on update.php as updates that</span></div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;<span class="comment"> * have not yet been run.</span></div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="comment"> * @param $module</span></div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="comment"> *   The module whose update will be run.</span></div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="comment"> * @param $number</span></div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="comment"> *   The update number to run.</span></div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;<span class="comment"> * @param $context</span></div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="comment"> *   The batch context array</span></div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00039"></a><span class="lineno"><a class="code" href="update_8inc.html#a7037652ade962feda993c9ddd041a950">   39</a></span>&#160;<span class="keyword">function</span> <a class="code" href="update_8inc.html#a7037652ade962feda993c9ddd041a950">drush_update_do_one</a>($module, $number, $dependency_map,  &amp;$context) {</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;  $function = $module . <span class="stringliteral">&#39;_update_&#39;</span> . $number;</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;  <span class="comment">// If this update was aborted in a previous step, or has a dependency that</span></div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;  <span class="comment">// was aborted in a previous step, go no further.</span></div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;  <span class="keywordflow">if</span> (!empty($context[<span class="stringliteral">&#39;results&#39;</span>][<span class="stringliteral">&#39;#abort&#39;</span>]) &amp;&amp; array_intersect($context[<span class="stringliteral">&#39;results&#39;</span>][<span class="stringliteral">&#39;#abort&#39;</span>], array_merge($dependency_map, array($function)))) {</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;    <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;  }</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;  $context[<span class="stringliteral">&#39;log&#39;</span>] = FALSE;</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;  \Drupal::moduleHandler()-&gt;loadInclude($module, <span class="stringliteral">&#39;install&#39;</span>);</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;  $ret = array();</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;  <span class="keywordflow">if</span> (function_exists($function)) {</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    <span class="keywordflow">try</span> {</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;      <span class="keywordflow">if</span> ($context[<span class="stringliteral">&#39;log&#39;</span>]) {</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;        Database::startLog($function);</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;      }</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;      <a class="code" href="group__logging.html#ga47324b65808524558a488916b150dd51">drush_log</a>(<span class="stringliteral">&quot;Executing &quot;</span> . $function);</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;      $ret[<span class="stringliteral">&#39;results&#39;</span>][<span class="stringliteral">&#39;query&#39;</span>] = $function($context[<span class="stringliteral">&#39;sandbox&#39;</span>]);</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;      $ret[<span class="stringliteral">&#39;results&#39;</span>][<span class="stringliteral">&#39;success&#39;</span>] = TRUE;</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;    }</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;    <span class="comment">// @TODO We may want to do different error handling for different exception</span></div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;    <span class="comment">// types, but for now we&#39;ll just print the message.</span></div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;    <span class="keywordflow">catch</span> (Exception $e) {</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;      $ret[<span class="stringliteral">&#39;#abort&#39;</span>] = array(<span class="stringliteral">&#39;success&#39;</span> =&gt; FALSE, <span class="stringliteral">&#39;query&#39;</span> =&gt; $e-&gt;getMessage());</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;      <a class="code" href="group__errorhandling.html#ga23fe9e1e8c1e5ade39256106044b6da4">drush_set_error</a>(<span class="stringliteral">&#39;DRUPAL_EXCEPTION&#39;</span>, $e-&gt;getMessage());</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    }</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;    <span class="keywordflow">if</span> ($context[<span class="stringliteral">&#39;log&#39;</span>]) {</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;      $ret[<span class="stringliteral">&#39;queries&#39;</span>] = Database::getLog($function);</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;    }</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;  }</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;  <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;    $ret[<span class="stringliteral">&#39;#abort&#39;</span>] = array(<span class="stringliteral">&#39;success&#39;</span> =&gt; FALSE);</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;    <a class="code" href="group__errorhandling.html#ga23fe9e1e8c1e5ade39256106044b6da4">drush_set_error</a>(<span class="stringliteral">&#39;DRUSH_UPDATE_FUNCTION_NOT_FOUND&#39;</span>, <a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;Update function @function not found&#39;</span>, array(<span class="stringliteral">&#39;@function&#39;</span> =&gt; $function)));</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;  }</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;  <span class="keywordflow">if</span> (isset($context[<span class="stringliteral">&#39;sandbox&#39;</span>][<span class="stringliteral">&#39;#finished&#39;</span>])) {</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;    $context[<span class="stringliteral">&#39;finished&#39;</span>] = $context[<span class="stringliteral">&#39;sandbox&#39;</span>][<span class="stringliteral">&#39;#finished&#39;</span>];</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;    unset($context[<span class="stringliteral">&#39;sandbox&#39;</span>][<span class="stringliteral">&#39;#finished&#39;</span>]);</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;  }</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;  <span class="keywordflow">if</span> (!isset($context[<span class="stringliteral">&#39;results&#39;</span>][$module])) {</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;    $context[<span class="stringliteral">&#39;results&#39;</span>][$module] = array();</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;  }</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;  <span class="keywordflow">if</span> (!isset($context[<span class="stringliteral">&#39;results&#39;</span>][$module][$number])) {</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;    $context[<span class="stringliteral">&#39;results&#39;</span>][$module][$number] = array();</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;  }</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;  $context[<span class="stringliteral">&#39;results&#39;</span>][$module][$number] = array_merge($context[<span class="stringliteral">&#39;results&#39;</span>][$module][$number], $ret);</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;  <span class="keywordflow">if</span> (!empty($ret[<span class="stringliteral">&#39;#abort&#39;</span>])) {</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;    <span class="comment">// Record this function in the list of updates that were aborted.</span></div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;    $context[<span class="stringliteral">&#39;results&#39;</span>][<span class="stringliteral">&#39;#abort&#39;</span>][] = $function;</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;  }</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;  <span class="comment">// Record the schema update if it was completed successfully.</span></div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;  <span class="keywordflow">if</span> ($context[<span class="stringliteral">&#39;finished&#39;</span>] == 1 &amp;&amp; empty($ret[<span class="stringliteral">&#39;#abort&#39;</span>])) {</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;    drupal_set_installed_schema_version($module, $number);</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;  }</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;  $context[<span class="stringliteral">&#39;message&#39;</span>] = <span class="stringliteral">&#39;Performing &#39;</span> . $function;</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;}</div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;<span class="keyword">function</span> update_main() {</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;  <span class="comment">// In D8, we expect to be in full bootstrap.</span></div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;  drush_bootstrap_to_phase(DRUSH_BOOTSTRAP_DRUPAL_FULL);</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;  require_once DRUPAL_ROOT . <span class="stringliteral">&#39;/core/includes/install.inc&#39;</span>;</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;  require_once DRUPAL_ROOT . <span class="stringliteral">&#39;/core/includes/update.inc&#39;</span>;</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;  drupal_load_updates();</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;  update_fix_compatibility();</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;  <span class="comment">// Pending hook_update_N() implementations.</span></div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;  $pending = update_get_update_list();</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;  <span class="comment">// Pending hook_post_update_X() implementations.</span></div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;  $post_updates = \Drupal::service(<span class="stringliteral">&#39;update.post_update_registry&#39;</span>)-&gt;getPendingUpdateInformation();</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;  $start = array();</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;  $change_summary = [];</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;  <span class="keywordflow">if</span> (<a class="code" href="context_8inc.html#afe91fb3e5219ecb2208c3b036b1f0cb8">drush_get_option</a>(<span class="stringliteral">&#39;entity-updates&#39;</span>, FALSE)) {</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;    $change_summary = \Drupal::entityDefinitionUpdateManager()-&gt;getChangeSummary();</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;  }</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;</div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;  <span class="comment">// Print a list of pending updates for this module and get confirmation.</span></div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;  <span class="keywordflow">if</span> (count($pending) || count($change_summary) || count($post_updates)) {</div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    <a class="code" href="group__outputfunctions.html#ga63acbb94925d6d2693e235e966bba740">drush_print</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;The following updates are pending:&#39;</span>));</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;    <a class="code" href="group__outputfunctions.html#ga63acbb94925d6d2693e235e966bba740">drush_print</a>();</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;    <span class="keywordflow">foreach</span> ($change_summary as $entity_type_id =&gt; $changes) {</div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;      <a class="code" href="group__outputfunctions.html#ga63acbb94925d6d2693e235e966bba740">drush_print</a>($entity_type_id . <span class="stringliteral">&#39; entity type : &#39;</span>);</div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;      <span class="keywordflow">foreach</span> ($changes as $change) {</div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;        <a class="code" href="group__outputfunctions.html#ga63acbb94925d6d2693e235e966bba740">drush_print</a>(strip_tags($change), 2);</div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;      }</div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;    }</div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;    <span class="keywordflow">foreach</span> (array(<span class="stringliteral">&#39;update&#39;</span>, <span class="stringliteral">&#39;post_update&#39;</span>) as $update_type) {</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;      $updates = $update_type == <span class="stringliteral">&#39;update&#39;</span> ? $pending : $post_updates;</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;      <span class="keywordflow">foreach</span> ($updates as $module =&gt; $updates) {</div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;        <span class="keywordflow">if</span> (isset($updates[<span class="stringliteral">&#39;start&#39;</span>])) {</div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;          <a class="code" href="group__outputfunctions.html#ga63acbb94925d6d2693e235e966bba740">drush_print</a>($module . <span class="stringliteral">&#39; module : &#39;</span>);</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;          <span class="keywordflow">if</span> (!empty($updates[<span class="stringliteral">&#39;pending&#39;</span>])) {</div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;            $start += [$module =&gt; array()];</div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;</div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;            $start[$module] = array_merge($start[$module], $updates[<span class="stringliteral">&#39;pending&#39;</span>]);</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;            <span class="keywordflow">foreach</span> ($updates[<span class="stringliteral">&#39;pending&#39;</span>] as $update) {</div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;              <a class="code" href="group__outputfunctions.html#ga63acbb94925d6d2693e235e966bba740">drush_print</a>(strip_tags($update), 2);</div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;            }</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;          }</div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;          <a class="code" href="group__outputfunctions.html#ga63acbb94925d6d2693e235e966bba740">drush_print</a>();</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;        }</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;      }</div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;    }</div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;</div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;    <span class="keywordflow">if</span> (!<a class="code" href="group__userinput.html#gaa4169b83ff9dc4222af95d376b21268b">drush_confirm</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;Do you wish to run all pending updates?&#39;</span>))) {</div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;      <span class="keywordflow">return</span> <a class="code" href="group__errorhandling.html#ga366aaafdf8c774a58653c64a65b6d91c">drush_user_abort</a>();</div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;    }</div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;</div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;    <a class="code" href="update_8inc.html#a9d3453110a57090b86046f2e442287ed">drush_update_batch</a>($start);</div>
<div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;  }</div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;  <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;    <a class="code" href="group__logging.html#ga47324b65808524558a488916b150dd51">drush_log</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&quot;No database updates required&quot;</span>), LogLevel::SUCCESS);</div>
<div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;  }</div>
<div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;</div>
<div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;  <span class="keywordflow">return</span> count($pending) + count($change_summary) + count($post_updates);</div>
<div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;}</div>
<div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;<span class="keyword">function</span> _update_batch_command($id) {</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;  <span class="comment">// In D8, we expect to be in full bootstrap.</span></div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;  drush_bootstrap_to_phase(DRUSH_BOOTSTRAP_DRUPAL_FULL);</div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;</div>
<div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;  <a class="code" href="includes_2batch_8inc.html#af470f96043a86e75e72cb186abf518ce">drush_batch_command</a>($id);</div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;}</div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;<span class="comment"> * Start the database update batch process.</span></div>
<div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00180"></a><span class="lineno"><a class="code" href="update_8inc.html#a9d3453110a57090b86046f2e442287ed">  180</a></span>&#160;<span class="keyword">function</span> <a class="code" href="update_8inc.html#a9d3453110a57090b86046f2e442287ed">drush_update_batch</a>() {</div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;  $start = drush_get_update_list();</div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;  <span class="comment">// Resolve any update dependencies to determine the actual updates that will</span></div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;  <span class="comment">// be run and the order they will be run in.</span></div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;  $updates = update_resolve_dependencies($start);</div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;</div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;  <span class="comment">// Store the dependencies for each update function in an array which the</span></div>
<div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;  <span class="comment">// batch API can pass in to the batch operation each time it is called. (We</span></div>
<div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;  <span class="comment">// do not store the entire update dependency array here because it is</span></div>
<div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;  <span class="comment">// potentially very large.)</span></div>
<div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;  $dependency_map = array();</div>
<div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;  <span class="keywordflow">foreach</span> ($updates as $function =&gt; $update) {</div>
<div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;    $dependency_map[$function] = !empty($update[<span class="stringliteral">&#39;reverse_paths&#39;</span>]) ? array_keys($update[<span class="stringliteral">&#39;reverse_paths&#39;</span>]) : array();</div>
<div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;  }</div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;</div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;  $operations = array();</div>
<div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;</div>
<div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;  <span class="keywordflow">foreach</span> ($updates as $update) {</div>
<div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;    <span class="keywordflow">if</span> ($update[<span class="stringliteral">&#39;allowed&#39;</span>]) {</div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;      <span class="comment">// Set the installed version of each module so updates will start at the</span></div>
<div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;      <span class="comment">// correct place. (The updates are already sorted, so we can simply base</span></div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;      <span class="comment">// this on the first one we come across in the above foreach loop.)</span></div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;      <span class="keywordflow">if</span> (isset($start[$update[<span class="stringliteral">&#39;module&#39;</span>]])) {</div>
<div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;        drupal_set_installed_schema_version($update[<span class="stringliteral">&#39;module&#39;</span>], $update[<span class="stringliteral">&#39;number&#39;</span>] - 1);</div>
<div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;        unset($start[$update[<span class="stringliteral">&#39;module&#39;</span>]]);</div>
<div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;      }</div>
<div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;      <span class="comment">// Add this update function to the batch.</span></div>
<div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;      $function = $update[<span class="stringliteral">&#39;module&#39;</span>] . <span class="stringliteral">&#39;_update_&#39;</span> . $update[<span class="stringliteral">&#39;number&#39;</span>];</div>
<div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;      $operations[] = array(<span class="stringliteral">&#39;drush_update_do_one&#39;</span>, array($update[<span class="stringliteral">&#39;module&#39;</span>], $update[<span class="stringliteral">&#39;number&#39;</span>], $dependency_map[$function]));</div>
<div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;    }</div>
<div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;  }</div>
<div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;</div>
<div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;  <span class="comment">// Apply post update hooks.</span></div>
<div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;  $post_updates = \Drupal::service(<span class="stringliteral">&#39;update.post_update_registry&#39;</span>)-&gt;getPendingUpdateFunctions();</div>
<div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;  <span class="keywordflow">if</span> ($post_updates) {</div>
<div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;    $operations[] = [<span class="stringliteral">&#39;drush_drupal_cache_clear_all&#39;</span>, []];</div>
<div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;    <span class="keywordflow">foreach</span> ($post_updates as $function) {</div>
<div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;      $operations[] = [<span class="stringliteral">&#39;update_invoke_post_update&#39;</span>, [$function]];</div>
<div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;    }</div>
<div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;  }</div>
<div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;</div>
<div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;  <span class="comment">// Lastly, perform entity definition updates, which will update storage</span></div>
<div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160;  <span class="comment">// schema if needed. If module update functions need to work with specific</span></div>
<div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;  <span class="comment">// entity schema they should call the entity update service for the specific</span></div>
<div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;  <span class="comment">// update themselves.</span></div>
<div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;  <span class="comment">// @see \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface::applyEntityUpdate()</span></div>
<div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;  <span class="comment">// @see \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface::applyFieldUpdate()</span></div>
<div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;  <span class="keywordflow">if</span> (<a class="code" href="context_8inc.html#afe91fb3e5219ecb2208c3b036b1f0cb8">drush_get_option</a>(<span class="stringliteral">&#39;entity-updates&#39;</span>, FALSE) &amp;&amp;  \Drupal::entityDefinitionUpdateManager()-&gt;needsUpdates()) {</div>
<div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;    $operations[] = array(<span class="stringliteral">&#39;drush_update_entity_definitions&#39;</span>, array());</div>
<div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;  }</div>
<div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;</div>
<div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;  $batch[<span class="stringliteral">&#39;operations&#39;</span>] = $operations;</div>
<div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;  $batch += array(</div>
<div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;    <span class="stringliteral">&#39;title&#39;</span> =&gt; <span class="stringliteral">&#39;Updating&#39;</span>,</div>
<div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160;    <span class="stringliteral">&#39;init_message&#39;</span> =&gt; <span class="stringliteral">&#39;Starting updates&#39;</span>,</div>
<div class="line"><a name="l00235"></a><span class="lineno">  235</span>&#160;    <span class="stringliteral">&#39;error_message&#39;</span> =&gt; <span class="stringliteral">&#39;An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference.&#39;</span>,</div>
<div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160;    <span class="stringliteral">&#39;finished&#39;</span> =&gt; <span class="stringliteral">&#39;drush_update_finished&#39;</span>,</div>
<div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;    <span class="stringliteral">&#39;file&#39;</span> =&gt; <span class="stringliteral">&#39;includes/update.inc&#39;</span>,</div>
<div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;  );</div>
<div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160;  batch_set($batch);</div>
<div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;  \Drupal::service(<span class="stringliteral">&#39;state&#39;</span>)-&gt;set(<span class="stringliteral">&#39;system.maintenance_mode&#39;</span>, TRUE);</div>
<div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;  <a class="code" href="includes_2batch_8inc.html#a706c51a974d149cdc701f47f9843143b">drush_backend_batch_process</a>(<span class="stringliteral">&#39;updatedb-batch-process&#39;</span>);</div>
<div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;  \Drupal::service(<span class="stringliteral">&#39;state&#39;</span>)-&gt;set(<span class="stringliteral">&#39;system.maintenance_mode&#39;</span>, FALSE);</div>
<div class="line"><a name="l00243"></a><span class="lineno">  243</span>&#160;}</div>
<div class="line"><a name="l00244"></a><span class="lineno">  244</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160;<span class="comment"> * Apply entity schema updates.</span></div>
<div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00248"></a><span class="lineno"><a class="code" href="update_8inc.html#ae66700aba90420adf4ef0b6fb6161394">  248</a></span>&#160;<span class="keyword">function</span> <a class="code" href="update_8inc.html#ae66700aba90420adf4ef0b6fb6161394">drush_update_entity_definitions</a>(&amp;$context) {</div>
<div class="line"><a name="l00249"></a><span class="lineno">  249</span>&#160;  <span class="keywordflow">try</span> {</div>
<div class="line"><a name="l00250"></a><span class="lineno">  250</span>&#160;    \Drupal::entityDefinitionUpdateManager()-&gt;applyUpdates();</div>
<div class="line"><a name="l00251"></a><span class="lineno">  251</span>&#160;  }</div>
<div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;  <span class="keywordflow">catch</span> (EntityStorageException $e) {</div>
<div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;    watchdog_exception(<span class="stringliteral">&#39;update&#39;</span>, $e);</div>
<div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;    $variables = Error::decodeException($e);</div>
<div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;    unset($variables[<span class="stringliteral">&#39;backtrace&#39;</span>]);</div>
<div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;    <span class="comment">// The exception message is run through</span></div>
<div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160;    <span class="comment">// \Drupal\Component\Utility\SafeMarkup::checkPlain() by</span></div>
<div class="line"><a name="l00258"></a><span class="lineno">  258</span>&#160;    <span class="comment">// \Drupal\Core\Utility\Error::decodeException().</span></div>
<div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;    $ret[<span class="stringliteral">&#39;#abort&#39;</span>] = array(<span class="stringliteral">&#39;success&#39;</span> =&gt; FALSE, <span class="stringliteral">&#39;query&#39;</span> =&gt; t(<span class="stringliteral">&#39;%type: !message in %function (line %line of %file).&#39;</span>, $variables));</div>
<div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160;    $context[<span class="stringliteral">&#39;results&#39;</span>][<span class="stringliteral">&#39;core&#39;</span>][<span class="stringliteral">&#39;update_entity_definitions&#39;</span>] = $ret;</div>
<div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;    $context[<span class="stringliteral">&#39;results&#39;</span>][<span class="stringliteral">&#39;#abort&#39;</span>][] = <span class="stringliteral">&#39;update_entity_definitions&#39;</span>;</div>
<div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;  }</div>
<div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;}</div>
<div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;</div>
<div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160;<span class="comment">// Copy of protected \Drupal\system\Controller\DbUpdateController::getModuleUpdates.</span></div>
<div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160;<span class="keyword">function</span> drush_get_update_list() {</div>
<div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;  $return = array();</div>
<div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160;  $updates = update_get_update_list();</div>
<div class="line"><a name="l00269"></a><span class="lineno">  269</span>&#160;  <span class="keywordflow">foreach</span> ($updates as $module =&gt; $update) {</div>
<div class="line"><a name="l00270"></a><span class="lineno">  270</span>&#160;    $return[$module] = $update[<span class="stringliteral">&#39;start&#39;</span>];</div>
<div class="line"><a name="l00271"></a><span class="lineno">  271</span>&#160;  }</div>
<div class="line"><a name="l00272"></a><span class="lineno">  272</span>&#160;</div>
<div class="line"><a name="l00273"></a><span class="lineno">  273</span>&#160;  <span class="keywordflow">return</span> $return;</div>
<div class="line"><a name="l00274"></a><span class="lineno">  274</span>&#160;}</div>
<div class="line"><a name="l00275"></a><span class="lineno">  275</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00276"></a><span class="lineno">  276</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00277"></a><span class="lineno">  277</span>&#160;<span class="comment"> * Process and display any returned update output.</span></div>
<div class="line"><a name="l00278"></a><span class="lineno">  278</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00279"></a><span class="lineno">  279</span>&#160;<span class="comment"> * @see \Drupal\system\Controller\DbUpdateController::batchFinished()</span></div>
<div class="line"><a name="l00280"></a><span class="lineno">  280</span>&#160;<span class="comment"> * @see \Drupal\system\Controller\DbUpdateController::results()</span></div>
<div class="line"><a name="l00281"></a><span class="lineno">  281</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00282"></a><span class="lineno"><a class="code" href="update_8inc.html#ad6ef60e0ddad8b4b6b4321c4c5b0e003">  282</a></span>&#160;<span class="keyword">function</span> <a class="code" href="update_8inc.html#ad6ef60e0ddad8b4b6b4321c4c5b0e003">drush_update_finished</a>($success, $results, $operations) {</div>
<div class="line"><a name="l00283"></a><span class="lineno">  283</span>&#160;</div>
<div class="line"><a name="l00284"></a><span class="lineno">  284</span>&#160;  <span class="keywordflow">if</span> (!<a class="code" href="context_8inc.html#afe91fb3e5219ecb2208c3b036b1f0cb8">drush_get_option</a>(<span class="stringliteral">&#39;cache-clear&#39;</span>, TRUE)) {</div>
<div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;    <a class="code" href="group__logging.html#ga47324b65808524558a488916b150dd51">drush_log</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&quot;Skipping cache-clear operation due to --cache-clear=0 option.&quot;</span>), LogLevel::WARNING);</div>
<div class="line"><a name="l00286"></a><span class="lineno">  286</span>&#160;  }</div>
<div class="line"><a name="l00287"></a><span class="lineno">  287</span>&#160;  <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00288"></a><span class="lineno">  288</span>&#160;    drupal_flush_all_caches();</div>
<div class="line"><a name="l00289"></a><span class="lineno">  289</span>&#160;  }</div>
<div class="line"><a name="l00290"></a><span class="lineno">  290</span>&#160;</div>
<div class="line"><a name="l00291"></a><span class="lineno">  291</span>&#160;  <span class="keywordflow">foreach</span> ($results as $module =&gt; $updates) {</div>
<div class="line"><a name="l00292"></a><span class="lineno">  292</span>&#160;    <span class="keywordflow">if</span> ($module != <span class="stringliteral">&#39;#abort&#39;</span>) {</div>
<div class="line"><a name="l00293"></a><span class="lineno">  293</span>&#160;      <span class="keywordflow">foreach</span> ($updates as $number =&gt; $queries) {</div>
<div class="line"><a name="l00294"></a><span class="lineno">  294</span>&#160;        <span class="keywordflow">foreach</span> ($queries as $query) {</div>
<div class="line"><a name="l00295"></a><span class="lineno">  295</span>&#160;          <span class="comment">// If there is no message for this update, don&#39;t show anything.</span></div>
<div class="line"><a name="l00296"></a><span class="lineno">  296</span>&#160;          <span class="keywordflow">if</span> (empty($query[<span class="stringliteral">&#39;query&#39;</span>])) {</div>
<div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;            <span class="keywordflow">continue</span>;</div>
<div class="line"><a name="l00298"></a><span class="lineno">  298</span>&#160;          }</div>
<div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;</div>
<div class="line"><a name="l00300"></a><span class="lineno">  300</span>&#160;          <span class="keywordflow">if</span> ($query[<span class="stringliteral">&#39;success&#39;</span>]) {</div>
<div class="line"><a name="l00301"></a><span class="lineno">  301</span>&#160;            <a class="code" href="group__logging.html#ga47324b65808524558a488916b150dd51">drush_log</a>(strip_tags($query[<span class="stringliteral">&#39;query&#39;</span>]));</div>
<div class="line"><a name="l00302"></a><span class="lineno">  302</span>&#160;          }</div>
<div class="line"><a name="l00303"></a><span class="lineno">  303</span>&#160;          <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00304"></a><span class="lineno">  304</span>&#160;            <a class="code" href="group__errorhandling.html#ga23fe9e1e8c1e5ade39256106044b6da4">drush_set_error</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;Failed: &#39;</span>) . strip_tags($query[<span class="stringliteral">&#39;query&#39;</span>]));</div>
<div class="line"><a name="l00305"></a><span class="lineno">  305</span>&#160;          }</div>
<div class="line"><a name="l00306"></a><span class="lineno">  306</span>&#160;        }</div>
<div class="line"><a name="l00307"></a><span class="lineno">  307</span>&#160;      }</div>
<div class="line"><a name="l00308"></a><span class="lineno">  308</span>&#160;    }</div>
<div class="line"><a name="l00309"></a><span class="lineno">  309</span>&#160;  }</div>
<div class="line"><a name="l00310"></a><span class="lineno">  310</span>&#160;}</div>
<div class="line"><a name="l00311"></a><span class="lineno">  311</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00312"></a><span class="lineno">  312</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00313"></a><span class="lineno">  313</span>&#160;<span class="comment"> * Return a 2 item array with</span></div>
<div class="line"><a name="l00314"></a><span class="lineno">  314</span>&#160;<span class="comment"> *  - an array where each item is a 3 item associative array describing a pending update.</span></div>
<div class="line"><a name="l00315"></a><span class="lineno">  315</span>&#160;<span class="comment"> *  - an array listing the first update to run, keyed by module.</span></div>
<div class="line"><a name="l00316"></a><span class="lineno">  316</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00317"></a><span class="lineno"><a class="code" href="update_8inc.html#ad074fc63b51c042f4d752543db9ad0e6">  317</a></span>&#160;<span class="keyword">function</span> <a class="code" href="update_8inc.html#ad074fc63b51c042f4d752543db9ad0e6">updatedb_status</a>() {</div>
<div class="line"><a name="l00318"></a><span class="lineno">  318</span>&#160;  $pending = update_get_update_list();</div>
<div class="line"><a name="l00319"></a><span class="lineno">  319</span>&#160;</div>
<div class="line"><a name="l00320"></a><span class="lineno">  320</span>&#160;  $return = array();</div>
<div class="line"><a name="l00321"></a><span class="lineno">  321</span>&#160;  <span class="comment">// Ensure system module&#39;s updates run first.</span></div>
<div class="line"><a name="l00322"></a><span class="lineno">  322</span>&#160;  $start[<span class="stringliteral">&#39;system&#39;</span>] = array();</div>
<div class="line"><a name="l00323"></a><span class="lineno">  323</span>&#160;</div>
<div class="line"><a name="l00324"></a><span class="lineno">  324</span>&#160;  <span class="keywordflow">foreach</span> (\Drupal::entityDefinitionUpdateManager()-&gt;getChangeSummary() as $entity_type_id =&gt; $changes) {</div>
<div class="line"><a name="l00325"></a><span class="lineno">  325</span>&#160;    <span class="keywordflow">foreach</span> ($changes as $change) {</div>
<div class="line"><a name="l00326"></a><span class="lineno">  326</span>&#160;      $return[] = array(</div>
<div class="line"><a name="l00327"></a><span class="lineno">  327</span>&#160;        <span class="stringliteral">&#39;module&#39;</span> =&gt; <a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;@type entity type&#39;</span>, array(<span class="stringliteral">&#39;@type&#39;</span> =&gt; $entity_type_id)), <span class="stringliteral">&#39;update_id&#39;</span> =&gt; <span class="stringliteral">&#39;&#39;</span>, <span class="stringliteral">&#39;description&#39;</span> =&gt; strip_tags($change));</div>
<div class="line"><a name="l00328"></a><span class="lineno">  328</span>&#160;    }</div>
<div class="line"><a name="l00329"></a><span class="lineno">  329</span>&#160;  }</div>
<div class="line"><a name="l00330"></a><span class="lineno">  330</span>&#160;</div>
<div class="line"><a name="l00331"></a><span class="lineno">  331</span>&#160;  <span class="comment">// Print a list of pending updates for this module and get confirmation.</span></div>
<div class="line"><a name="l00332"></a><span class="lineno">  332</span>&#160;  <span class="keywordflow">foreach</span> ($pending as $module =&gt; $updates) {</div>
<div class="line"><a name="l00333"></a><span class="lineno">  333</span>&#160;    <span class="keywordflow">if</span> (isset($updates[<span class="stringliteral">&#39;start&#39;</span>]))  {</div>
<div class="line"><a name="l00334"></a><span class="lineno">  334</span>&#160;      <span class="keywordflow">foreach</span> ($updates[<span class="stringliteral">&#39;pending&#39;</span>] as $update_id =&gt; $description) {</div>
<div class="line"><a name="l00335"></a><span class="lineno">  335</span>&#160;        <span class="comment">// Strip cruft from front.</span></div>
<div class="line"><a name="l00336"></a><span class="lineno">  336</span>&#160;        $description = str_replace($update_id . <span class="stringliteral">&#39; -   &#39;</span>, <span class="stringliteral">&#39;&#39;</span>, $description);</div>
<div class="line"><a name="l00337"></a><span class="lineno">  337</span>&#160;        $return[] = array(<span class="stringliteral">&#39;module&#39;</span> =&gt; ucfirst($module), <span class="stringliteral">&#39;update_id&#39;</span> =&gt; $update_id, <span class="stringliteral">&#39;description&#39;</span> =&gt; $description);</div>
<div class="line"><a name="l00338"></a><span class="lineno">  338</span>&#160;      }</div>
<div class="line"><a name="l00339"></a><span class="lineno">  339</span>&#160;      <span class="keywordflow">if</span> (isset($updates[<span class="stringliteral">&#39;start&#39;</span>])) {</div>
<div class="line"><a name="l00340"></a><span class="lineno">  340</span>&#160;        $start[$module] = $updates[<span class="stringliteral">&#39;start&#39;</span>];</div>
<div class="line"><a name="l00341"></a><span class="lineno">  341</span>&#160;      }</div>
<div class="line"><a name="l00342"></a><span class="lineno">  342</span>&#160;    }</div>
<div class="line"><a name="l00343"></a><span class="lineno">  343</span>&#160;  }</div>
<div class="line"><a name="l00344"></a><span class="lineno">  344</span>&#160;</div>
<div class="line"><a name="l00345"></a><span class="lineno">  345</span>&#160;  <span class="keywordflow">return</span> array($return, $start);</div>
<div class="line"><a name="l00346"></a><span class="lineno">  346</span>&#160;}</div>
<div class="line"><a name="l00347"></a><span class="lineno">  347</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00348"></a><span class="lineno">  348</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00349"></a><span class="lineno">  349</span>&#160;<span class="comment"> * Apply pending entity schema updates.</span></div>
<div class="line"><a name="l00350"></a><span class="lineno">  350</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00351"></a><span class="lineno"><a class="code" href="update_8inc.html#a32ab583b70acb38949ea75843692b3ed">  351</a></span>&#160;<span class="keyword">function</span> <a class="code" href="update_8inc.html#a32ab583b70acb38949ea75843692b3ed">entity_updates_main</a>() {</div>
<div class="line"><a name="l00352"></a><span class="lineno">  352</span>&#160;  $change_summary = \Drupal::entityDefinitionUpdateManager()-&gt;getChangeSummary();</div>
<div class="line"><a name="l00353"></a><span class="lineno">  353</span>&#160;  <span class="keywordflow">if</span> (!empty($change_summary)) {</div>
<div class="line"><a name="l00354"></a><span class="lineno">  354</span>&#160;    <a class="code" href="group__outputfunctions.html#ga63acbb94925d6d2693e235e966bba740">drush_print</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;The following updates are pending:&#39;</span>));</div>
<div class="line"><a name="l00355"></a><span class="lineno">  355</span>&#160;    <a class="code" href="group__outputfunctions.html#ga63acbb94925d6d2693e235e966bba740">drush_print</a>();</div>
<div class="line"><a name="l00356"></a><span class="lineno">  356</span>&#160;</div>
<div class="line"><a name="l00357"></a><span class="lineno">  357</span>&#160;    <span class="keywordflow">foreach</span> ($change_summary as $entity_type_id =&gt; $changes) {</div>
<div class="line"><a name="l00358"></a><span class="lineno">  358</span>&#160;      <a class="code" href="group__outputfunctions.html#ga63acbb94925d6d2693e235e966bba740">drush_print</a>($entity_type_id . <span class="stringliteral">&#39; entity type : &#39;</span>);</div>
<div class="line"><a name="l00359"></a><span class="lineno">  359</span>&#160;      <span class="keywordflow">foreach</span> ($changes as $change) {</div>
<div class="line"><a name="l00360"></a><span class="lineno">  360</span>&#160;        <a class="code" href="group__outputfunctions.html#ga63acbb94925d6d2693e235e966bba740">drush_print</a>(strip_tags($change), 2);</div>
<div class="line"><a name="l00361"></a><span class="lineno">  361</span>&#160;      }</div>
<div class="line"><a name="l00362"></a><span class="lineno">  362</span>&#160;    }</div>
<div class="line"><a name="l00363"></a><span class="lineno">  363</span>&#160;</div>
<div class="line"><a name="l00364"></a><span class="lineno">  364</span>&#160;    <span class="keywordflow">if</span> (!<a class="code" href="group__userinput.html#gaa4169b83ff9dc4222af95d376b21268b">drush_confirm</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;Do you wish to run all pending updates?&#39;</span>))) {</div>
<div class="line"><a name="l00365"></a><span class="lineno">  365</span>&#160;      <span class="keywordflow">return</span> <a class="code" href="group__errorhandling.html#ga366aaafdf8c774a58653c64a65b6d91c">drush_user_abort</a>();</div>
<div class="line"><a name="l00366"></a><span class="lineno">  366</span>&#160;    }</div>
<div class="line"><a name="l00367"></a><span class="lineno">  367</span>&#160;</div>
<div class="line"><a name="l00368"></a><span class="lineno">  368</span>&#160;    $operations[] = array(<span class="stringliteral">&#39;drush_update_entity_definitions&#39;</span>, array());</div>
<div class="line"><a name="l00369"></a><span class="lineno">  369</span>&#160;</div>
<div class="line"><a name="l00370"></a><span class="lineno">  370</span>&#160;</div>
<div class="line"><a name="l00371"></a><span class="lineno">  371</span>&#160;    $batch[<span class="stringliteral">&#39;operations&#39;</span>] = $operations;</div>
<div class="line"><a name="l00372"></a><span class="lineno">  372</span>&#160;    $batch += array(</div>
<div class="line"><a name="l00373"></a><span class="lineno">  373</span>&#160;      <span class="stringliteral">&#39;title&#39;</span> =&gt; <span class="stringliteral">&#39;Updating&#39;</span>,</div>
<div class="line"><a name="l00374"></a><span class="lineno">  374</span>&#160;      <span class="stringliteral">&#39;init_message&#39;</span> =&gt; <span class="stringliteral">&#39;Starting updates&#39;</span>,</div>
<div class="line"><a name="l00375"></a><span class="lineno">  375</span>&#160;      <span class="stringliteral">&#39;error_message&#39;</span> =&gt; <span class="stringliteral">&#39;An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference.&#39;</span>,</div>
<div class="line"><a name="l00376"></a><span class="lineno">  376</span>&#160;      <span class="stringliteral">&#39;finished&#39;</span> =&gt; <span class="stringliteral">&#39;drush_update_finished&#39;</span>,</div>
<div class="line"><a name="l00377"></a><span class="lineno">  377</span>&#160;      <span class="stringliteral">&#39;file&#39;</span> =&gt; <span class="stringliteral">&#39;includes/update.inc&#39;</span>,</div>
<div class="line"><a name="l00378"></a><span class="lineno">  378</span>&#160;    );</div>
<div class="line"><a name="l00379"></a><span class="lineno">  379</span>&#160;    batch_set($batch);</div>
<div class="line"><a name="l00380"></a><span class="lineno">  380</span>&#160;    \Drupal::service(<span class="stringliteral">&#39;state&#39;</span>)-&gt;set(<span class="stringliteral">&#39;system.maintenance_mode&#39;</span>, TRUE);</div>
<div class="line"><a name="l00381"></a><span class="lineno">  381</span>&#160;    <a class="code" href="includes_2batch_8inc.html#a706c51a974d149cdc701f47f9843143b">drush_backend_batch_process</a>(<span class="stringliteral">&#39;updatedb-batch-process&#39;</span>);</div>
<div class="line"><a name="l00382"></a><span class="lineno">  382</span>&#160;    \Drupal::service(<span class="stringliteral">&#39;state&#39;</span>)-&gt;set(<span class="stringliteral">&#39;system.maintenance_mode&#39;</span>, FALSE);</div>
<div class="line"><a name="l00383"></a><span class="lineno">  383</span>&#160;  }</div>
<div class="line"><a name="l00384"></a><span class="lineno">  384</span>&#160;  <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00385"></a><span class="lineno">  385</span>&#160;    <a class="code" href="group__logging.html#ga47324b65808524558a488916b150dd51">drush_log</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&quot;No entity schema updates required&quot;</span>), LogLevel::SUCCESS);</div>
<div class="line"><a name="l00386"></a><span class="lineno">  386</span>&#160;  }</div>
<div class="line"><a name="l00387"></a><span class="lineno">  387</span>&#160;}</div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Wed Nov 2 2016 07:28:53 for Drush by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.1.2
</small></address>
</body>
</html>