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

  1. 7.x doxygen/html/update__7_8inc_source.html
  2. master doxygen/html/update__7_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  * Global flag to identify update.php run, and so avoid various unwanted
14  * operations, such as hook_init() and hook_exit() invokes, css/js preprocessing
15  * and translation, and solve some theming issues. This flag is checked on several
16  * places in Drupal code (not just update.php).
17  */
18 define('MAINTENANCE_MODE', 'update');
19 
20 /**
21  * Drupal's update.inc has functions that are in previous update_X.inc files
22  * for example, update_check_incompatibility() which can prove useful when
23  * enabling modules.
24  */
25 require_once DRUSH_DRUPAL_CORE . '/includes/update.inc';
26 /**
27  * Returns (and optionally stores) extra requirements that only apply during
28  * particular parts of the update.php process.
29  */
30 function update_extra_requirements($requirements = NULL) {
31  static $extra_requirements = array();
32  if (isset($requirements)) {
33  $extra_requirements += $requirements;
34  }
35  return $extra_requirements;
36 }
37 
38 /**
39  * Perform one update and store the results which will later be displayed on
40  * the finished page.
41  *
42  * An update function can force the current and all later updates for this
43  * module to abort by returning a $ret array with an element like:
44  * $ret['#abort'] = array('success' => FALSE, 'query' => 'What went wrong');
45  * The schema version will not be updated in this case, and all the
46  * aborted updates will continue to appear on update.php as updates that
47  * have not yet been run.
48  *
49  * @param $module
50  * The module whose update will be run.
51  * @param $number
52  * The update number to run.
53  * @param $context
54  * The batch context array
55  */
56 function drush_update_do_one($module, $number, $dependency_map, &$context) {
57  $function = $module . '_update_' . $number;
58 
59  // If this update was aborted in a previous step, or has a dependency that
60  // was aborted in a previous step, go no further.
61  if (!empty($context['results']['#abort']) && array_intersect($context['results']['#abort'], array_merge($dependency_map, array($function)))) {
62  return;
63  }
64 
65  $context['log'] = FALSE;
66 
67  $ret = array();
68  if (function_exists($function)) {
69  try {
70  if ($context['log']) {
71  Database::startLog($function);
72  }
73 
74  drush_log("Executing " . $function);
75  $ret['results']['query'] = $function($context['sandbox']);
76 
77  // If the update hook returned a status message (common in batch updates),
78  // show it to the user.
79  if ($ret['results']['query']) {
80  drush_log($ret['results']['query'], LogLevel::OK);
81  }
82 
83  $ret['results']['success'] = TRUE;
84  }
85  // @TODO We may want to do different error handling for different exception
86  // types, but for now we'll just print the message.
87  catch (Exception $e) {
88  $ret['#abort'] = array('success' => FALSE, 'query' => $e->getMessage());
89  drush_set_error('DRUPAL_EXCEPTION', $e->getMessage());
90  }
91 
92  if ($context['log']) {
93  $ret['queries'] = Database::getLog($function);
94  }
95  }
96 
97  if (isset($context['sandbox']['#finished'])) {
98  $context['finished'] = $context['sandbox']['#finished'];
99  unset($context['sandbox']['#finished']);
100  }
101 
102  if (!isset($context['results'][$module])) {
103  $context['results'][$module] = array();
104  }
105  if (!isset($context['results'][$module][$number])) {
106  $context['results'][$module][$number] = array();
107  }
108  $context['results'][$module][$number] = array_merge($context['results'][$module][$number], $ret);
109 
110  if (!empty($ret['#abort'])) {
111  // Record this function in the list of updates that were aborted.
112  $context['results']['#abort'][] = $function;
113  }
114 
115  // Record the schema update if it was completed successfully.
116  if ($context['finished'] == 1 && empty($ret['#abort'])) {
117  drupal_set_installed_schema_version($module, $number);
118  }
119 
120  $context['message'] = 'Performed update: ' . $function;
121 }
122 
123 /**
124  * Check update requirements and report any errors.
125  */
127  $warnings = FALSE;
128 
129  // Check the system module and update.php requirements only.
130  $requirements = system_requirements('update');
131  $requirements += update_extra_requirements();
132 
133  // If there are issues, report them.
134  foreach ($requirements as $requirement) {
135  if (isset($requirement['severity']) && $requirement['severity'] > REQUIREMENT_OK) {
136  $message = isset($requirement['description']) ? $requirement['description'] : '';
137  if (isset($requirement['value']) && $requirement['value']) {
138  $message .= ' (Currently using ' . $requirement['title'] . ' ' . $requirement['value'] . ')';
139  }
140  $warnings = TRUE;
141  drupal_set_message($message, LogLevel::WARNING);
142  }
143  }
144  return $warnings;
145 }
146 
147 
148 function update_main_prepare() {
149  // Some unavoidable errors happen because the database is not yet up-to-date.
150  // Our custom error handler is not yet installed, so we just suppress them.
152 
153  // We prepare a minimal bootstrap for the update requirements check to avoid
154  // reaching the PHP memory limit.
155  $core = DRUSH_DRUPAL_CORE;
156  require_once $core . '/includes/bootstrap.inc';
157  require_once $core . '/includes/common.inc';
158  require_once $core . '/includes/file.inc';
159  require_once $core . '/includes/entity.inc';
160  include_once $core . '/includes/unicode.inc';
161 
162  update_prepare_d7_bootstrap();
163  drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
164 
165  require_once $core . '/includes/install.inc';
166  require_once $core . '/modules/system/system.install';
167 
168  // Load module basics.
169  include_once $core . '/includes/module.inc';
170  $module_list['system']['filename'] = 'modules/system/system.module';
171  module_list(TRUE, FALSE, FALSE, $module_list);
172  drupal_load('module', 'system');
173 
174  // Reset the module_implements() cache so that any new hook implementations
175  // in updated code are picked up.
176  module_implements('', FALSE, TRUE);
177 
178  // Set up $language, since the installer components require it.
179  drupal_language_initialize();
180 
181  // Set up theme system for the maintenance page.
182  drupal_maintenance_theme();
183 
184  // Check the update requirements for Drupal.
186 
187  // update_fix_d7_requirements() needs to run before bootstrapping beyond path.
188  // So bootstrap to DRUPAL_BOOTSTRAP_LANGUAGE then include unicode.inc.
189  drupal_bootstrap(DRUPAL_BOOTSTRAP_LANGUAGE);
190 
191  update_fix_d7_requirements();
192 
193  // Clear the module_implements() cache before the full bootstrap. The calls
194  // above to drupal_maintenance_theme() and update_check_requirements() have
195  // invoked hooks before all modules have actually been loaded by the full
196  // bootstrap. This means that the module_implements() results for any hooks
197  // that have been invoked, including hook_module_implements_alter(), is a
198  // smaller set of modules than should be returned normally.
200  module_implements('', FALSE, TRUE);
201 
202  // Now proceed with a full bootstrap.
203 
205  drupal_maintenance_theme();
206 
207  drush_errors_on();
208 
209  include_once DRUPAL_ROOT . '/includes/batch.inc';
210  drupal_load_updates();
211 
212  update_fix_compatibility();
213 
214  // Change query-strings on css/js files to enforce reload for all users.
215  _drupal_flush_css_js();
216  // Flush the cache of all data for the update status module.
217  if (db_table_exists('cache_update')) {
218  cache_clear_all('*', 'cache_update', TRUE);
219  }
220 
221  module_list(TRUE, FALSE, TRUE);
222 }
223 
224 function update_main() {
226 
227  list($pending, $start) = updatedb_status();
228  if ($pending) {
229  // @todo get table header working.
230  // $headers = array(dt('Module'), dt('ID'), dt('Description'));
231  drush_print_table($pending);
232  if (!drush_confirm(dt('Do you wish to run all pending updates?'))) {
233  return drush_user_abort();
234  }
235  drush_update_batch($start);
236  }
237  else {
238  drush_log(dt("No database updates required"), LogLevel::SUCCESS);
239  }
240 
241  return count($pending);
242 }
243 
244 function _update_batch_command($id) {
246  drush_batch_command($id);
247 }
248 
249 /**
250  * Start the database update batch process.
251  *
252  * @param $start
253  * An array of all the modules and which update to start at.
254  * @param $redirect
255  * Path to redirect to when the batch has finished processing.
256  * @param $url
257  * URL of the batch processing page (should only be used for separate
258  * scripts like update.php).
259  * @param $batch
260  * Optional parameters to pass into the batch API.
261  * @param $redirect_callback
262  * (optional) Specify a function to be called to redirect to the progressive
263  * processing page.
264  */
265 function drush_update_batch($start) {
266  // Resolve any update dependencies to determine the actual updates that will
267  // be run and the order they will be run in.
268  $updates = update_resolve_dependencies($start);
269 
270  // Store the dependencies for each update function in an array which the
271  // batch API can pass in to the batch operation each time it is called. (We
272  // do not store the entire update dependency array here because it is
273  // potentially very large.)
274  $dependency_map = array();
275  foreach ($updates as $function => $update) {
276  $dependency_map[$function] = !empty($update['reverse_paths']) ? array_keys($update['reverse_paths']) : array();
277  }
278 
279  $operations = array();
280  foreach ($updates as $update) {
281  if ($update['allowed']) {
282  // Set the installed version of each module so updates will start at the
283  // correct place. (The updates are already sorted, so we can simply base
284  // this on the first one we come across in the above foreach loop.)
285  if (isset($start[$update['module']])) {
286  drupal_set_installed_schema_version($update['module'], $update['number'] - 1);
287  unset($start[$update['module']]);
288  }
289  // Add this update function to the batch.
290  $function = $update['module'] . '_update_' . $update['number'];
291  $operations[] = array('drush_update_do_one', array($update['module'], $update['number'], $dependency_map[$function]));
292  }
293  }
294 
295  $batch['operations'] = $operations;
296  $batch += array(
297  'title' => 'Updating',
298  'init_message' => 'Starting updates',
299  '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.',
300  'finished' => 'drush_update_finished',
301  'file' => 'includes/update.inc',
302  );
303  batch_set($batch);
304  drush_backend_batch_process('updatedb-batch-process');
305 }
306 
307 
308 
309 function drush_update_finished($success, $results, $operations) {
310  // Nothing to do here. All caches already cleared. Kept as documentation of 'finished' callback.
311 }
312 
313 /**
314  * Return a 2 item array with
315  * - an array where each item is a 3 item associative array describing a pending update.
316  * - an array listing the first update to run, keyed by module.
317  */
318 function updatedb_status() {
319  $pending = update_get_update_list();
320 
321  $return = array();
322  // Ensure system module's updates run first.
323  $start['system'] = array();
324 
325  // Print a list of pending updates for this module and get confirmation.
326  foreach ($pending as $module => $updates) {
327  if (isset($updates['start'])) {
328  foreach ($updates['pending'] as $update_id => $description) {
329  // Strip cruft from front.
330  $description = str_replace($update_id . ' - ', '', $description);
331  $return[] = array('module' => ucfirst($module), 'update_id' => $update_id, 'description' => $description);
332  }
333  if (isset($updates['start'])) {
334  $start[$module] = $updates['start'];
335  }
336  }
337  }
338  return array($return, $start);
339 }

File

doxygen/html/update__7_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_7.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_7.inc</div>  </div>
</div><!--header-->
<div class="contents">
<a href="update__7_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"> * Global flag to identify update.php run, and so avoid various unwanted</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment"> * operations, such as hook_init() and hook_exit() invokes, css/js preprocessing</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment"> * and translation, and solve some theming issues. This flag is checked on several</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment"> * places in Drupal code (not just update.php).</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00018"></a><span class="lineno"><a class="code" href="update__7_8inc.html#a0849e56e1546e2b900cf36ef28e36e9f">   18</a></span>&#160;define(<span class="stringliteral">&#39;MAINTENANCE_MODE&#39;</span>, <span class="stringliteral">&#39;update&#39;</span>);</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</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="l00022"></a><span class="lineno">   22</span>&#160;<span class="comment"> * for example, update_check_incompatibility() which can prove useful when</span></div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="comment"> * enabling modules.</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;require_once DRUSH_DRUPAL_CORE . <span class="stringliteral">&#39;/includes/update.inc&#39;</span>;<span class="comment"></span></div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="comment"> * Returns (and optionally stores) extra requirements that only apply during</span></div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="comment"> * particular parts of the update.php process.</span></div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00030"></a><span class="lineno"><a class="code" href="update__7_8inc.html#a0c14cba656eed6f94996df5798223b9a">   30</a></span>&#160;<span class="keyword">function</span> <a class="code" href="update__7_8inc.html#a0c14cba656eed6f94996df5798223b9a">update_extra_requirements</a>($requirements = NULL) {</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;  <span class="keyword">static</span> $extra_requirements = array();</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;  <span class="keywordflow">if</span> (isset($requirements)) {</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;    $extra_requirements += $requirements;</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;  }</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;  <span class="keywordflow">return</span> $extra_requirements;</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;}</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="comment"></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">   39</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="l00040"></a><span class="lineno">   40</span>&#160;<span class="comment"> * the finished page.</span></div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</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="l00043"></a><span class="lineno">   43</span>&#160;<span class="comment"> * module to abort by returning a $ret array with an element like:</span></div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</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="l00045"></a><span class="lineno">   45</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="l00046"></a><span class="lineno">   46</span>&#160;<span class="comment"> * aborted updates will continue to appear on update.php as updates that</span></div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;<span class="comment"> * have not yet been run.</span></div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;<span class="comment"> * @param $module</span></div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;<span class="comment"> *   The module whose update will be run.</span></div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;<span class="comment"> * @param $number</span></div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;<span class="comment"> *   The update number to run.</span></div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;<span class="comment"> * @param $context</span></div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;<span class="comment"> *   The batch context array</span></div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00056"></a><span class="lineno"><a class="code" href="update__7_8inc.html#a7037652ade962feda993c9ddd041a950">   56</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="l00057"></a><span class="lineno">   57</span>&#160;  $function = $module . <span class="stringliteral">&#39;_update_&#39;</span> . $number;</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;  <span class="comment">// If this update was aborted in a previous step, or has a dependency that</span></div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;  <span class="comment">// was aborted in a previous step, go no further.</span></div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</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="l00062"></a><span class="lineno">   62</span>&#160;    <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;  }</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;  $context[<span class="stringliteral">&#39;log&#39;</span>] = FALSE;</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;  $ret = array();</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;  <span class="keywordflow">if</span> (function_exists($function)) {</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;    <span class="keywordflow">try</span> {</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;        Database::startLog($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;      <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="l00075"></a><span class="lineno">   75</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="l00076"></a><span class="lineno">   76</span>&#160;</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;      <span class="comment">// If the update hook returned a status message (common in batch updates),</span></div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;      <span class="comment">// show it to the user.</span></div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;      <span class="keywordflow">if</span> ($ret[<span class="stringliteral">&#39;results&#39;</span>][<span class="stringliteral">&#39;query&#39;</span>]) {</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;        <a class="code" href="group__logging.html#ga47324b65808524558a488916b150dd51">drush_log</a>($ret[<span class="stringliteral">&#39;results&#39;</span>][<span class="stringliteral">&#39;query&#39;</span>], LogLevel::OK);</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;      }</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;      $ret[<span class="stringliteral">&#39;results&#39;</span>][<span class="stringliteral">&#39;success&#39;</span>] = TRUE;</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;    }</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;    <span class="comment">// @TODO We may want to do different error handling for different exception</span></div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;    <span class="comment">// types, but for now we&#39;ll just print the message.</span></div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;    <span class="keywordflow">catch</span> (Exception $e) {</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</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="l00089"></a><span class="lineno">   89</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="l00090"></a><span class="lineno">   90</span>&#160;    }</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> ($context[<span class="stringliteral">&#39;log&#39;</span>]) {</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;      $ret[<span class="stringliteral">&#39;queries&#39;</span>] = Database::getLog($function);</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;    }</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="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="l00098"></a><span class="lineno">   98</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="l00099"></a><span class="lineno">   99</span>&#160;    unset($context[<span class="stringliteral">&#39;sandbox&#39;</span>][<span class="stringliteral">&#39;#finished&#39;</span>]);</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;  <span class="keywordflow">if</span> (!isset($context[<span class="stringliteral">&#39;results&#39;</span>][$module])) {</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;    $context[<span class="stringliteral">&#39;results&#39;</span>][$module] = array();</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="keywordflow">if</span> (!isset($context[<span class="stringliteral">&#39;results&#39;</span>][$module][$number])) {</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;    $context[<span class="stringliteral">&#39;results&#39;</span>][$module][$number] = array();</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;  }</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</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="l00109"></a><span class="lineno">  109</span>&#160;</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;  <span class="keywordflow">if</span> (!empty($ret[<span class="stringliteral">&#39;#abort&#39;</span>])) {</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;    <span class="comment">// Record this function in the list of updates that were aborted.</span></div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;    $context[<span class="stringliteral">&#39;results&#39;</span>][<span class="stringliteral">&#39;#abort&#39;</span>][] = $function;</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;</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;  <span class="comment">// Record the schema update if it was completed successfully.</span></div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</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="l00117"></a><span class="lineno">  117</span>&#160;    drupal_set_installed_schema_version($module, $number);</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;  }</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;  $context[<span class="stringliteral">&#39;message&#39;</span>] = <span class="stringliteral">&#39;Performed update: &#39;</span> . $function;</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;<span class="comment"></span></div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;<span class="comment"> * Check update requirements and report any errors.</span></div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00126"></a><span class="lineno"><a class="code" href="update__7_8inc.html#ad0b8cf7510033800502402c275add53b">  126</a></span>&#160;<span class="keyword">function</span> <a class="code" href="update__7_8inc.html#ad0b8cf7510033800502402c275add53b">update_check_requirements</a>() {</div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;  $warnings = FALSE;</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;</div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;  <span class="comment">// Check the system module and update.php requirements only.</span></div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;  $requirements = system_requirements(<span class="stringliteral">&#39;update&#39;</span>);</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;  $requirements += <a class="code" href="update__7_8inc.html#a0c14cba656eed6f94996df5798223b9a">update_extra_requirements</a>();</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;</div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;  <span class="comment">// If there are issues, report them.</span></div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;  <span class="keywordflow">foreach</span> ($requirements as $requirement) {</div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;    <span class="keywordflow">if</span> (isset($requirement[<span class="stringliteral">&#39;severity&#39;</span>]) &amp;&amp; $requirement[<span class="stringliteral">&#39;severity&#39;</span>] &gt; REQUIREMENT_OK) {</div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;      $message = isset($requirement[<span class="stringliteral">&#39;description&#39;</span>]) ? $requirement[<span class="stringliteral">&#39;description&#39;</span>] : <span class="stringliteral">&#39;&#39;</span>;</div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;      <span class="keywordflow">if</span> (isset($requirement[<span class="stringliteral">&#39;value&#39;</span>]) &amp;&amp; $requirement[<span class="stringliteral">&#39;value&#39;</span>]) {</div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;        $message .= <span class="stringliteral">&#39; (Currently using &#39;</span> . $requirement[<span class="stringliteral">&#39;title&#39;</span>] . <span class="charliteral">&#39; &#39;</span> . $requirement[<span class="stringliteral">&#39;value&#39;</span>] . <span class="charliteral">&#39;)&#39;</span>;</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;      }</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;      $warnings = TRUE;</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;      drupal_set_message($message, LogLevel::WARNING);</div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;    }</div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;  }</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;  <span class="keywordflow">return</span> $warnings;</div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;}</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;</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;<span class="keyword">function</span> update_main_prepare() {</div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;  <span class="comment">// Some unavoidable errors happen because the database is not yet up-to-date.</span></div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;  <span class="comment">// Our custom error handler is not yet installed, so we just suppress them.</span></div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;  <a class="code" href="group__errorhandling.html#ga4d3fc14a9eef57a06ac4bab523744462">drush_errors_off</a>();</div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;  <span class="comment">// We prepare a minimal bootstrap for the update requirements check to avoid</span></div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;  <span class="comment">// reaching the PHP memory limit.</span></div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;  $core = DRUSH_DRUPAL_CORE;</div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;  require_once $core . <span class="stringliteral">&#39;/includes/bootstrap.inc&#39;</span>;</div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;  require_once $core . <span class="stringliteral">&#39;/includes/common.inc&#39;</span>;</div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;  require_once $core . <span class="stringliteral">&#39;/includes/file.inc&#39;</span>;</div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;  require_once $core . <span class="stringliteral">&#39;/includes/entity.inc&#39;</span>;</div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;  include_once $core . <span class="stringliteral">&#39;/includes/unicode.inc&#39;</span>;</div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;</div>
<div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;  update_prepare_d7_bootstrap();</div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;  drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);</div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;</div>
<div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;  require_once $core . <span class="stringliteral">&#39;/includes/install.inc&#39;</span>;</div>
<div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;  require_once $core . <span class="stringliteral">&#39;/modules/system/system.install&#39;</span>;</div>
<div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;</div>
<div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;  <span class="comment">// Load module basics.</span></div>
<div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;  include_once $core . <span class="stringliteral">&#39;/includes/module.inc&#39;</span>;</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;  $module_list[<span class="stringliteral">&#39;system&#39;</span>][<span class="stringliteral">&#39;filename&#39;</span>] = <span class="stringliteral">&#39;modules/system/system.module&#39;</span>;</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;  module_list(TRUE, FALSE, FALSE, $module_list);</div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;  drupal_load(<span class="stringliteral">&#39;module&#39;</span>, <span class="stringliteral">&#39;system&#39;</span>);</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;  <span class="comment">// Reset the module_implements() cache so that any new hook implementations</span></div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;  <span class="comment">// in updated code are picked up.</span></div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;  module_implements(<span class="stringliteral">&#39;&#39;</span>, FALSE, TRUE);</div>
<div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;</div>
<div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;  <span class="comment">// Set up $language, since the installer components require it.</span></div>
<div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;  drupal_language_initialize();</div>
<div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;</div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;  <span class="comment">// Set up theme system for the maintenance page.</span></div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;  drupal_maintenance_theme();</div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;</div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;  <span class="comment">// Check the update requirements for Drupal.</span></div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;  <a class="code" href="update__7_8inc.html#ad0b8cf7510033800502402c275add53b">update_check_requirements</a>();</div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;</div>
<div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;  <span class="comment">// update_fix_d7_requirements() needs to run before bootstrapping beyond path.</span></div>
<div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;  <span class="comment">// So bootstrap to DRUPAL_BOOTSTRAP_LANGUAGE then include unicode.inc.</span></div>
<div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;  drupal_bootstrap(DRUPAL_BOOTSTRAP_LANGUAGE);</div>
<div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;</div>
<div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;  update_fix_d7_requirements();</div>
<div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;</div>
<div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;  <span class="comment">// Clear the module_implements() cache before the full bootstrap. The calls</span></div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;  <span class="comment">// above to drupal_maintenance_theme() and update_check_requirements() have</span></div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;  <span class="comment">// invoked hooks before all modules have actually been loaded by the full</span></div>
<div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;  <span class="comment">// bootstrap. This means that the module_implements() results for any hooks</span></div>
<div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;  <span class="comment">// that have been invoked, including hook_module_implements_alter(), is a</span></div>
<div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;  <span class="comment">// smaller set of modules than should be returned normally.</span></div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;  <span class="comment">// @see https://github.com/drush-ops/drush/pull/399</span></div>
<div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;  module_implements(<span class="stringliteral">&#39;&#39;</span>, FALSE, TRUE);</div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;</div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;  <span class="comment">// Now proceed with a full bootstrap.</span></div>
<div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;</div>
<div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;  drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);</div>
<div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;  drupal_maintenance_theme();</div>
<div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;</div>
<div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;  <a class="code" href="group__errorhandling.html#ga303bcdf8b73c31b19ba4de4f2f6ef41b">drush_errors_on</a>();</div>
<div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;</div>
<div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;  include_once DRUPAL_ROOT . <span class="stringliteral">&#39;/includes/batch.inc&#39;</span>;</div>
<div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;  drupal_load_updates();</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;  update_fix_compatibility();</div>
<div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;</div>
<div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;   <span class="comment">// Change query-strings on css/js files to enforce reload for all users.</span></div>
<div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;  _drupal_flush_css_js();</div>
<div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;  <span class="comment">// Flush the cache of all data for the update status module.</span></div>
<div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;  <span class="keywordflow">if</span> (db_table_exists(<span class="stringliteral">&#39;cache_update&#39;</span>)) {</div>
<div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;    cache_clear_all(<span class="charliteral">&#39;*&#39;</span>, <span class="stringliteral">&#39;cache_update&#39;</span>, TRUE);</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;  module_list(TRUE, FALSE, TRUE);</div>
<div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160;}</div>
<div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;</div>
<div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;<span class="keyword">function</span> update_main() {</div>
<div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;  update_main_prepare();</div>
<div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;</div>
<div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;  list($pending, $start) = <a class="code" href="update_8inc.html#ad074fc63b51c042f4d752543db9ad0e6">updatedb_status</a>();</div>
<div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;  <span class="keywordflow">if</span> ($pending) {</div>
<div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;    <span class="comment">// @todo get table header working.</span></div>
<div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;    <span class="comment">// $headers = array(dt(&#39;Module&#39;), dt(&#39;ID&#39;), dt(&#39;Description&#39;));</span></div>
<div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;    <a class="code" href="group__outputfunctions.html#ga2dfb80176f98c67097334acfa98211cd">drush_print_table</a>($pending);</div>
<div class="line"><a name="l00232"></a><span class="lineno">  232</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="l00233"></a><span class="lineno">  233</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="l00234"></a><span class="lineno">  234</span>&#160;    }</div>
<div class="line"><a name="l00235"></a><span class="lineno">  235</span>&#160;    <a class="code" href="update_8inc.html#a9d3453110a57090b86046f2e442287ed">drush_update_batch</a>($start);</div>
<div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160;  }</div>
<div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;  <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00238"></a><span class="lineno">  238</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="l00239"></a><span class="lineno">  239</span>&#160;  }</div>
<div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;</div>
<div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;  <span class="keywordflow">return</span> count($pending);</div>
<div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;}</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="keyword">function</span> _update_batch_command($id) {</div>
<div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160;  update_main_prepare();</div>
<div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160;  <a class="code" href="includes_2batch_8inc.html#af470f96043a86e75e72cb186abf518ce">drush_batch_command</a>($id);</div>
<div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;}</div>
<div class="line"><a name="l00248"></a><span class="lineno">  248</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00249"></a><span class="lineno">  249</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00250"></a><span class="lineno">  250</span>&#160;<span class="comment"> * Start the database update batch process.</span></div>
<div class="line"><a name="l00251"></a><span class="lineno">  251</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;<span class="comment"> * @param $start</span></div>
<div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;<span class="comment"> *   An array of all the modules and which update to start at.</span></div>
<div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;<span class="comment"> * @param $redirect</span></div>
<div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;<span class="comment"> *   Path to redirect to when the batch has finished processing.</span></div>
<div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;<span class="comment"> * @param $url</span></div>
<div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160;<span class="comment"> *   URL of the batch processing page (should only be used for separate</span></div>
<div class="line"><a name="l00258"></a><span class="lineno">  258</span>&#160;<span class="comment"> *   scripts like update.php).</span></div>
<div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;<span class="comment"> * @param $batch</span></div>
<div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160;<span class="comment"> *   Optional parameters to pass into the batch API.</span></div>
<div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;<span class="comment"> * @param $redirect_callback</span></div>
<div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;<span class="comment"> *   (optional) Specify a function to be called to redirect to the progressive</span></div>
<div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;<span class="comment"> *   processing page.</span></div>
<div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00265"></a><span class="lineno"><a class="code" href="update__7_8inc.html#acb7719984816f5c3fcf003a93e8a9947">  265</a></span>&#160;<span class="keyword">function</span> <a class="code" href="update_8inc.html#a9d3453110a57090b86046f2e442287ed">drush_update_batch</a>($start) {</div>
<div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160;  <span class="comment">// Resolve any update dependencies to determine the actual updates that will</span></div>
<div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;  <span class="comment">// be run and the order they will be run in.</span></div>
<div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160;  $updates = update_resolve_dependencies($start);</div>
<div class="line"><a name="l00269"></a><span class="lineno">  269</span>&#160;</div>
<div class="line"><a name="l00270"></a><span class="lineno">  270</span>&#160;  <span class="comment">// Store the dependencies for each update function in an array which the</span></div>
<div class="line"><a name="l00271"></a><span class="lineno">  271</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="l00272"></a><span class="lineno">  272</span>&#160;  <span class="comment">// do not store the entire update dependency array here because it is</span></div>
<div class="line"><a name="l00273"></a><span class="lineno">  273</span>&#160;  <span class="comment">// potentially very large.)</span></div>
<div class="line"><a name="l00274"></a><span class="lineno">  274</span>&#160;  $dependency_map = array();</div>
<div class="line"><a name="l00275"></a><span class="lineno">  275</span>&#160;  <span class="keywordflow">foreach</span> ($updates as $function =&gt; $update) {</div>
<div class="line"><a name="l00276"></a><span class="lineno">  276</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="l00277"></a><span class="lineno">  277</span>&#160;  }</div>
<div class="line"><a name="l00278"></a><span class="lineno">  278</span>&#160;</div>
<div class="line"><a name="l00279"></a><span class="lineno">  279</span>&#160;  $operations = array();</div>
<div class="line"><a name="l00280"></a><span class="lineno">  280</span>&#160;  <span class="keywordflow">foreach</span> ($updates as $update) {</div>
<div class="line"><a name="l00281"></a><span class="lineno">  281</span>&#160;    <span class="keywordflow">if</span> ($update[<span class="stringliteral">&#39;allowed&#39;</span>]) {</div>
<div class="line"><a name="l00282"></a><span class="lineno">  282</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="l00283"></a><span class="lineno">  283</span>&#160;      <span class="comment">// correct place. (The updates are already sorted, so we can simply base</span></div>
<div class="line"><a name="l00284"></a><span class="lineno">  284</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="l00285"></a><span class="lineno">  285</span>&#160;      <span class="keywordflow">if</span> (isset($start[$update[<span class="stringliteral">&#39;module&#39;</span>]])) {</div>
<div class="line"><a name="l00286"></a><span class="lineno">  286</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="l00287"></a><span class="lineno">  287</span>&#160;        unset($start[$update[<span class="stringliteral">&#39;module&#39;</span>]]);</div>
<div class="line"><a name="l00288"></a><span class="lineno">  288</span>&#160;      }</div>
<div class="line"><a name="l00289"></a><span class="lineno">  289</span>&#160;      <span class="comment">// Add this update function to the batch.</span></div>
<div class="line"><a name="l00290"></a><span class="lineno">  290</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="l00291"></a><span class="lineno">  291</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="l00292"></a><span class="lineno">  292</span>&#160;    }</div>
<div class="line"><a name="l00293"></a><span class="lineno">  293</span>&#160;  }</div>
<div class="line"><a name="l00294"></a><span class="lineno">  294</span>&#160;</div>
<div class="line"><a name="l00295"></a><span class="lineno">  295</span>&#160;  $batch[<span class="stringliteral">&#39;operations&#39;</span>] = $operations;</div>
<div class="line"><a name="l00296"></a><span class="lineno">  296</span>&#160;  $batch += array(</div>
<div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;    <span class="stringliteral">&#39;title&#39;</span> =&gt; <span class="stringliteral">&#39;Updating&#39;</span>,</div>
<div class="line"><a name="l00298"></a><span class="lineno">  298</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="l00299"></a><span class="lineno">  299</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="l00300"></a><span class="lineno">  300</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="l00301"></a><span class="lineno">  301</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="l00302"></a><span class="lineno">  302</span>&#160;  );</div>
<div class="line"><a name="l00303"></a><span class="lineno">  303</span>&#160;  batch_set($batch);</div>
<div class="line"><a name="l00304"></a><span class="lineno">  304</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="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;<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="l00310"></a><span class="lineno">  310</span>&#160;  <span class="comment">// Nothing to do here. All caches already cleared. Kept as documentation of &#39;finished&#39; callback.</span></div>
<div class="line"><a name="l00311"></a><span class="lineno">  311</span>&#160;}</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">/**</span></div>
<div class="line"><a name="l00314"></a><span class="lineno">  314</span>&#160;<span class="comment"> * Return a 2 item array with</span></div>
<div class="line"><a name="l00315"></a><span class="lineno">  315</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="l00316"></a><span class="lineno">  316</span>&#160;<span class="comment"> *  - an array listing the first update to run, keyed by module.</span></div>
<div class="line"><a name="l00317"></a><span class="lineno">  317</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00318"></a><span class="lineno"><a class="code" href="update__7_8inc.html#ad074fc63b51c042f4d752543db9ad0e6">  318</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="l00319"></a><span class="lineno">  319</span>&#160;  $pending = update_get_update_list();</div>
<div class="line"><a name="l00320"></a><span class="lineno">  320</span>&#160;</div>
<div class="line"><a name="l00321"></a><span class="lineno">  321</span>&#160;  $return = array();</div>
<div class="line"><a name="l00322"></a><span class="lineno">  322</span>&#160;  <span class="comment">// Ensure system module&#39;s updates run first.</span></div>
<div class="line"><a name="l00323"></a><span class="lineno">  323</span>&#160;  $start[<span class="stringliteral">&#39;system&#39;</span>] = array();</div>
<div class="line"><a name="l00324"></a><span class="lineno">  324</span>&#160;</div>
<div class="line"><a name="l00325"></a><span class="lineno">  325</span>&#160;  <span class="comment">// Print a list of pending updates for this module and get confirmation.</span></div>
<div class="line"><a name="l00326"></a><span class="lineno">  326</span>&#160;  <span class="keywordflow">foreach</span> ($pending as $module =&gt; $updates) {</div>
<div class="line"><a name="l00327"></a><span class="lineno">  327</span>&#160;    <span class="keywordflow">if</span> (isset($updates[<span class="stringliteral">&#39;start&#39;</span>]))  {</div>
<div class="line"><a name="l00328"></a><span class="lineno">  328</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="l00329"></a><span class="lineno">  329</span>&#160;        <span class="comment">// Strip cruft from front.</span></div>
<div class="line"><a name="l00330"></a><span class="lineno">  330</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="l00331"></a><span class="lineno">  331</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="l00332"></a><span class="lineno">  332</span>&#160;      }</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;        $start[$module] = $updates[<span class="stringliteral">&#39;start&#39;</span>];</div>
<div class="line"><a name="l00335"></a><span class="lineno">  335</span>&#160;      }</div>
<div class="line"><a name="l00336"></a><span class="lineno">  336</span>&#160;    }</div>
<div class="line"><a name="l00337"></a><span class="lineno">  337</span>&#160;  }</div>
<div class="line"><a name="l00338"></a><span class="lineno">  338</span>&#160;  <span class="keywordflow">return</span> array($return, $start);</div>
<div class="line"><a name="l00339"></a><span class="lineno">  339</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>