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

  1. 7.x doxygen/html/update__6_8inc_source.html
  2. master doxygen/html/update__6_8inc_source.html
update_6.inc
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 define('MAINTENANCE_MODE', 'update');
13 
14 
15 /**
16  * Add a column to a database using syntax appropriate for PostgreSQL.
17  * Save result of SQL commands in $ret array.
18  *
19  * Note: when you add a column with NOT NULL and you are not sure if there are
20  * already rows in the table, you MUST also add DEFAULT. Otherwise PostgreSQL
21  * won't work when the table is not empty, and db_add_column() will fail.
22  * To have an empty string as the default, you must use: 'default' => "''"
23  * in the $attributes array. If NOT NULL and DEFAULT are set the PostgreSQL
24  * version will set values of the added column in old rows to the
25  * DEFAULT value.
26  *
27  * @param $ret
28  * Array to which results will be added.
29  * @param $table
30  * Name of the table, without {}
31  * @param $column
32  * Name of the column
33  * @param $type
34  * Type of column
35  * @param $attributes
36  * Additional optional attributes. Recognized attributes:
37  * not null => TRUE|FALSE
38  * default => NULL|FALSE|value (the value must be enclosed in '' marks)
39  * @return
40  * nothing, but modifies $ret parameter.
41  */
42 function db_add_column(&$ret, $table, $column, $type, $attributes = array()) {
43  if (array_key_exists('not null', $attributes) and $attributes['not null']) {
44  $not_null = 'NOT NULL';
45  }
46  if (array_key_exists('default', $attributes)) {
47  if (!isset($attributes['default'])) {
48  $default_val = 'NULL';
49  $default = 'default NULL';
50  }
51  elseif ($attributes['default'] === FALSE) {
52  $default = '';
53  }
54  else {
55  $default_val = "$attributes[default]";
56  $default = "default $attributes[default]";
57  }
58  }
59 
60  $ret[] = update_sql("ALTER TABLE {". $table ."} ADD $column $type");
61  if (!empty($default)) {
62  $ret[] = update_sql("ALTER TABLE {". $table ."} ALTER $column SET $default");
63  }
64  if (!empty($not_null)) {
65  if (!empty($default)) {
66  $ret[] = update_sql("UPDATE {". $table ."} SET $column = $default_val");
67  }
68  $ret[] = update_sql("ALTER TABLE {". $table ."} ALTER $column SET NOT NULL");
69  }
70 }
71 
72 /**
73  * Change a column definition using syntax appropriate for PostgreSQL.
74  * Save result of SQL commands in $ret array.
75  *
76  * Remember that changing a column definition involves adding a new column
77  * and dropping an old one. This means that any indices, primary keys and
78  * sequences from serial-type columns are dropped and might need to be
79  * recreated.
80  *
81  * @param $ret
82  * Array to which results will be added.
83  * @param $table
84  * Name of the table, without {}
85  * @param $column
86  * Name of the column to change
87  * @param $column_new
88  * New name for the column (set to the same as $column if you don't want to change the name)
89  * @param $type
90  * Type of column
91  * @param $attributes
92  * Additional optional attributes. Recognized attributes:
93  * not null => TRUE|FALSE
94  * default => NULL|FALSE|value (with or without '', it won't be added)
95  * @return
96  * nothing, but modifies $ret parameter.
97  */
98 function db_change_column(&$ret, $table, $column, $column_new, $type, $attributes = array()) {
99  if (array_key_exists('not null', $attributes) and $attributes['not null']) {
100  $not_null = 'NOT NULL';
101  }
102  if (array_key_exists('default', $attributes)) {
103  if (!isset($attributes['default'])) {
104  $default_val = 'NULL';
105  $default = 'default NULL';
106  }
107  elseif ($attributes['default'] === FALSE) {
108  $default = '';
109  }
110  else {
111  $default_val = "$attributes[default]";
112  $default = "default $attributes[default]";
113  }
114  }
115 
116  $ret[] = update_sql("ALTER TABLE {". $table ."} RENAME $column TO ". $column ."_old");
117  $ret[] = update_sql("ALTER TABLE {". $table ."} ADD $column_new $type");
118  $ret[] = update_sql("UPDATE {". $table ."} SET $column_new = ". $column ."_old");
119  if ($default) { $ret[] = update_sql("ALTER TABLE {". $table ."} ALTER $column_new SET $default"); }
120  if ($not_null) { $ret[] = update_sql("ALTER TABLE {". $table ."} ALTER $column_new SET NOT NULL"); }
121  $ret[] = update_sql("ALTER TABLE {". $table ."} DROP ". $column ."_old");
122 }
123 
124 
125 /**
126  * Disable anything in the {system} table that is not compatible with the
127  * current version of Drupal core.
128  */
130  $ret = array();
131  $incompatible = array();
132  $query = db_query("SELECT name, type, status FROM {system} WHERE status = 1 AND type IN ('module','theme')");
133  while ($result = db_fetch_object($query)) {
134  if (update_check_incompatibility($result->name, $result->type)) {
135  $incompatible[] = $result->name;
136  drush_log(dt("!type !name is incompatible with this release of Drupal, and will be disabled.",
137  array("!type" => $result->type, '!name' => $result->name)), LogLevel::WARNING);
138  }
139  }
140  if (!empty($incompatible)) {
141 
142  $ret[] = update_sql("UPDATE {system} SET status = 0 WHERE name IN ('". implode("','", $incompatible) ."')");
143  }
144  return $ret;
145 }
146 
147 /**
148  * Helper function to test compatibility of a module or theme.
149  */
150 function update_check_incompatibility($name, $type = 'module') {
151  static $themes, $modules;
152 
153  // Store values of expensive functions for future use.
154  if (empty($themes) || empty($modules)) {
155  drush_include_engine('drupal', 'environment');
156  $themes = _system_theme_data();
157  $modules = module_rebuild_cache();
158  }
159 
160  if ($type == 'module' && isset($modules[$name])) {
161  $file = $modules[$name];
162  }
163  else if ($type == 'theme' && isset($themes[$name])) {
164  $file = $themes[$name];
165  }
166  if (!isset($file)
167  || !isset($file->info['core'])
168  || $file->info['core'] != drush_get_drupal_core_compatibility()
169  || version_compare(phpversion(), $file->info['php']) < 0) {
170  return TRUE;
171  }
172  return FALSE;
173 }
174 
175 /**
176  * Perform Drupal 5.x to 6.x updates that are required for update.php
177  * to function properly.
178  *
179  * This function runs when update.php is run the first time for 6.x,
180  * even before updates are selected or performed. It is important
181  * that if updates are not ultimately performed that no changes are
182  * made which make it impossible to continue using the prior version.
183  * Just adding columns is safe. However, renaming the
184  * system.description column to owner is not. Therefore, we add the
185  * system.owner column and leave it to system_update_6008() to copy
186  * the data from description and remove description. The same for
187  * renaming locales_target.locale to locales_target.language, which
188  * will be finished by locale_update_6002().
189  */
191  $ret = array();
192 
193  if (drupal_get_installed_schema_version('system') < 6000 && !variable_get('update_d6_requirements', FALSE)) {
194  $spec = array('type' => 'int', 'size' => 'small', 'default' => 0, 'not null' => TRUE);
195  db_add_field($ret, 'cache', 'serialized', $spec);
196  db_add_field($ret, 'cache_filter', 'serialized', $spec);
197  db_add_field($ret, 'cache_page', 'serialized', $spec);
198  db_add_field($ret, 'cache_menu', 'serialized', $spec);
199 
200  db_add_field($ret, 'system', 'info', array('type' => 'text'));
201  db_add_field($ret, 'system', 'owner', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
202  if (db_table_exists('locales_target')) {
203  db_add_field($ret, 'locales_target', 'language', array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''));
204  }
205  if (db_table_exists('locales_source')) {
206  db_add_field($ret, 'locales_source', 'textgroup', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => 'default'));
207  db_add_field($ret, 'locales_source', 'version', array('type' => 'varchar', 'length' => 20, 'not null' => TRUE, 'default' => 'none'));
208  }
209  variable_set('update_d6_requirements', TRUE);
210 
211  // Create the cache_block table. See system_update_6027() for more details.
212  $schema['cache_block'] = array(
213  'fields' => array(
214  'cid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
215  'data' => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'),
216  'expire' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
217  'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
218  'headers' => array('type' => 'text', 'not null' => FALSE),
219  'serialized' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)
220  ),
221  'indexes' => array('expire' => array('expire')),
222  'primary key' => array('cid'),
223  );
224  db_create_table($ret, 'cache_block', $schema['cache_block']);
225 
226  // Create the semaphore table now -- the menu system after 6.15 depends on
227  // this table, and menu code runs in updates prior to the table being
228  // created in its original update function, system_update_6054().
229  $schema['semaphore'] = array(
230  'fields' => array(
231  'name' => array(
232  'type' => 'varchar',
233  'length' => 255,
234  'not null' => TRUE,
235  'default' => ''),
236  'value' => array(
237  'type' => 'varchar',
238  'length' => 255,
239  'not null' => TRUE,
240  'default' => ''),
241  'expire' => array(
242  'type' => 'float',
243  'size' => 'big',
244  'not null' => TRUE),
245  ),
246  'indexes' => array('expire' => array('expire')),
247  'primary key' => array('name'),
248  );
249  db_create_table($ret, 'semaphore', $schema['semaphore']);
250  }
251 
252  return $ret;
253 }
254 
255 /**
256  * Check update requirements and report any errors.
257  */
259  // Check the system module requirements only.
260  $requirements = module_invoke('system', 'requirements', 'update');
261  $severity = drupal_requirements_severity($requirements);
262 
263  // If there are issues, report them.
264  if ($severity != REQUIREMENT_OK) {
265  foreach ($requirements as $requirement) {
266  if (isset($requirement['severity']) && $requirement['severity'] != REQUIREMENT_OK) {
267  $message = isset($requirement['description']) ? $requirement['description'] : '';
268  if (isset($requirement['value']) && $requirement['value']) {
269  $message .= ' (Currently using '. $requirement['title'] .' '. $requirement['value'] .')';
270  }
271  drush_log($message, LogLevel::WARNING);
272  }
273  }
274  }
275 }
276 
277 /**
278  * Create the batch table.
279  *
280  * This is part of the Drupal 5.x to 6.x migration.
281  */
283 
284  // If batch table exists, update is not necessary
285  if (db_table_exists('batch')) {
286  return;
287  }
288 
289  $schema['batch'] = array(
290  'fields' => array(
291  'bid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
292  'token' => array('type' => 'varchar', 'length' => 64, 'not null' => TRUE),
293  'timestamp' => array('type' => 'int', 'not null' => TRUE),
294  'batch' => array('type' => 'text', 'not null' => FALSE, 'size' => 'big')
295  ),
296  'primary key' => array('bid'),
297  'indexes' => array('token' => array('token')),
298  );
299 
300  $ret = array();
301  db_create_table($ret, 'batch', $schema['batch']);
302  return $ret;
303 }
304 
305 function update_main_prepare() {
306  global $profile;
307  // Some unavoidable errors happen because the database is not yet up-to-date.
308  // Our custom error handler is not yet installed, so we just suppress them.
310 
311  require_once './includes/bootstrap.inc';
312  // Minimum load of components.
313  // This differs from the Drupal 6 update.php workflow for compatbility with
314  // the Drupal 6 backport of module_implements() caching.
317  require_once './includes/install.inc';
318  require_once './includes/file.inc';
319  require_once './modules/system/system.install';
320 
321  // Load module basics.
322  include_once './includes/module.inc';
323  $module_list['system']['filename'] = 'modules/system/system.module';
324  $module_list['filter']['filename'] = 'modules/filter/filter.module';
325  module_list(TRUE, FALSE, FALSE, $module_list);
326  module_implements('', FALSE, TRUE);
327 
328  drupal_load('module', 'system');
329  drupal_load('module', 'filter');
330 
331  // Set up $language, since the installer components require it.
332  drupal_init_language();
333 
334  // Set up theme system for the maintenance page.
335  drupal_maintenance_theme();
336 
337  // Check the update requirements for Drupal.
339 
341  $profile = variable_get('install_profile', 'default');
342  // Updates only run reliably if user ID #1 is logged in. For example, node_delete() requires elevated perms in D5/6.
343  if (!drush_get_context('DRUSH_USER')) {
344  drush_set_option('user', 1);
346  }
347 
348  // This must happen *after* drupal_bootstrap(), since it calls
349  // variable_(get|set), which only works after a full bootstrap.
351 
352  // Turn error reporting back on. From now on, only fatal errors (which are
353  // not passed through the error handler) will cause a message to be printed.
354  drush_errors_on();
355 
356  // Perform Drupal 5.x to 6.x updates that are required for update.php to function properly.
358 
359  // Must unset $theme->status in order to safely rescan and repopulate
360  // the system table to ensure we have a full picture of the platform.
361  // This is needed because $theme->status is set to 0 in a call to
362  // list_themes() done by drupal_maintenance_theme().
363  // It is a issue with _system_theme_data() that returns its own cache
364  // variable and can be modififed by others. When this is fixed in
365  // drupal core we can remove this unset.
366  // For reference see: http://drupal.org/node/762754
367  $themes = _system_theme_data();
368  foreach ($themes as $theme) {
369  unset($theme->status);
370  }
372 
373  include_once './includes/batch.inc';
374  drupal_load_updates();
375 
376  // Disable anything in the {system} table that is not compatible with the current version of Drupal core.
378 }
379 
380 function update_main() {
382 
383  list($pending, $start) = updatedb_status();
384 
385  // Print a list of pending updates for this module and get confirmation.
386  if ($pending) {
387  // @todo get table header working
388  // array_unshift($pending, array(dt('Module'), dt('ID'), dt('Description')));
389  drush_print_table($pending, FALSE);
390  if (!drush_confirm(dt('Do you wish to run all pending updates?'))) {
391  return drush_user_abort();
392  }
393  // Proceed with running all pending updates.
394  $operations = array();
395  foreach ($start as $module => $version) {
396  drupal_set_installed_schema_version($module, $version - 1);
397  $updates = drupal_get_schema_versions($module);
398  $max_version = max($updates);
399  if ($version <= $max_version) {
400  drush_log(dt('Updating module @module from schema version @start to schema version @max', array('@module' => $module, '@start' => $version - 1, '@max' => $max_version)));
401  foreach ($updates as $update) {
402  if ($update >= $version) {
403  $operations[] = array('_update_do_one', array($module, $update));
404  }
405  }
406  }
407  else {
408  drush_log(dt('No database updates for module @module', array('@module' => $module)), LogLevel::SUCCESS);
409  }
410  }
411  $batch = array(
412  'operations' => $operations,
413  'title' => 'Updating',
414  'init_message' => 'Starting updates',
415  '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.',
416  'finished' => 'update_finished',
417  );
418  batch_set($batch);
419  $batch =& batch_get();
420  $batch['progressive'] = FALSE;
421  drush_backend_batch_process('updatedb-batch-process');
422  }
423  else {
424  drush_log(dt("No database updates required"), LogLevel::SUCCESS);
425  }
426 
427  return count($pending);
428 }
429 
430 /**
431  * A simplified version of the batch_do_one function from update.php
432  *
433  * This does not mess with sessions and the like, as it will be used
434  * from the command line
435  */
436 function _update_do_one($module, $number, &$context) {
437  // If updates for this module have been aborted
438  // in a previous step, go no further.
439  if (!empty($context['results'][$module]['#abort'])) {
440  return;
441  }
442 
443  $function = $module .'_update_'. $number;
444  drush_log("Executing $function", LogLevel::SUCCESS);
445 
446  if (function_exists($function)) {
447  $ret = $function($context['sandbox']);
448  $context['results'][$module] = $ret;
449  _drush_log_update_sql($ret);
450  }
451 
452  if (isset($ret['#finished'])) {
453  $context['finished'] = $ret['#finished'];
454  unset($ret['#finished']);
455  }
456 
457  if ($context['finished'] == 1 && empty($context['results'][$module]['#abort'])) {
458  drupal_set_installed_schema_version($module, $number);
459  }
460 
461 }
462 
463 function _update_batch_command($id) {
465  drush_batch_command($id);
466 }
467 
468 /**
469  * Return a 2 item array with
470  * - an array where each item is a 3 item associative array describing a pending update.
471  * - an array listing the first update to run, keyed by module.
472  */
473 function updatedb_status() {
474  $return = array();
475 
476  $modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE);
477  foreach ($modules as $module => $schema_version) {
478  $updates = drupal_get_schema_versions($module);
479  // Skip incompatible module updates completely, otherwise test schema versions.
480  if (!update_check_incompatibility($module) && $updates !== FALSE && $schema_version >= 0) {
481  // module_invoke returns NULL for nonexisting hooks, so if no updates
482  // are removed, it will == 0.
483  $last_removed = module_invoke($module, 'update_last_removed');
484  if ($schema_version < $last_removed) {
485  drush_set_error('PROVISION_DRUPAL_UPDATE_FAILED', dt( $module .' module can not be updated. Its schema version is '. $schema_version .'. Updates up to and including '. $last_removed .' have been removed in this release. In order to update '. $module .' module, you will first <a href="http://drupal.org/upgrade">need to upgrade</a> to the last version in which these updates were available.'));
486  continue;
487  }
488 
489  $updates = drupal_map_assoc($updates);
490 
491  // Record the starting update number for each module.
492  foreach (array_keys($updates) as $update) {
493  if ($update > $schema_version) {
494  $start[$module] = $update;
495  break;
496  }
497  }
498  if (isset($start['system'])) {
499  // Ensure system module's updates run first.
500  $start = array('system' => $start['system']) + $start;
501  }
502 
503  // Record any pending updates. Used for confirmation prompt.
504  foreach (array_keys($updates) as $update) {
505  if ($update > $schema_version) {
506  if (class_exists('ReflectionFunction')) {
507  // The description for an update comes from its Doxygen.
508  $func = new ReflectionFunction($module. '_update_'. $update);
509  $description = trim(str_replace(array("\n", '*', '/'), '', $func->getDocComment()));
510  }
511  if (empty($description)) {
512  $description = dt('description not available');
513  }
514 
515  $return[] = array('module' => ucfirst($module), 'update_id' => $update, 'description' => $description);
516  }
517  }
518  }
519  }
520 
521  return array($return, $start);
522 }

File

doxygen/html/update__6_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_6.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="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</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>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><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_6.inc</div>  </div>
</div><!--header-->
<div class="contents">
<a href="update__6_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;</div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;define(<span class="stringliteral">&#39;MAINTENANCE_MODE&#39;</span>, <span class="stringliteral">&#39;update&#39;</span>);</div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;</div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment"> * Add a column to a database using syntax appropriate for PostgreSQL.</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment"> * Save result of SQL commands in $ret array.</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="comment"> * Note: when you add a column with NOT NULL and you are not sure if there are</span></div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="comment"> * already rows in the table, you MUST also add DEFAULT. Otherwise PostgreSQL</span></div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="comment"> * won&#39;t work when the table is not empty, and db_add_column() will fail.</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="comment"> * To have an empty string as the default, you must use: &#39;default&#39; =&gt; &quot;&#39;&#39;&quot;</span></div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="comment"> * in the $attributes array. If NOT NULL and DEFAULT are set the PostgreSQL</span></div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="comment"> * version will set values of the added column in old rows to the</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="comment"> * DEFAULT value.</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"> * @param $ret</span></div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="comment"> *   Array to which results will be added.</span></div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="comment"> * @param $table</span></div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;<span class="comment"> *   Name of the table, without {}</span></div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="comment"> * @param $column</span></div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="comment"> *   Name of the column</span></div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="comment"> * @param $type</span></div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;<span class="comment"> *   Type of column</span></div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="comment"> * @param $attributes</span></div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;<span class="comment"> *   Additional optional attributes. Recognized attributes:</span></div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="comment"> *     not null =&gt; TRUE|FALSE</span></div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="comment"> *     default  =&gt; NULL|FALSE|value (the value must be enclosed in &#39;&#39; marks)</span></div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="comment"> * @return</span></div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<span class="comment"> *   nothing, but modifies $ret parameter.</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"><a class="code" href="update__6_8inc.html#a68749bcc3e7949ede51c5dd2db91f39e">   42</a></span>&#160;<span class="keyword">function</span> <a class="code" href="update__6_8inc.html#a68749bcc3e7949ede51c5dd2db91f39e">db_add_column</a>(&amp;$ret, $table, $column, $type, $attributes = array()) {</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;  <span class="keywordflow">if</span> (array_key_exists(<span class="stringliteral">&#39;not null&#39;</span>, $attributes) and $attributes[<span class="stringliteral">&#39;not null&#39;</span>]) {</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    $not_null = <span class="stringliteral">&#39;NOT NULL&#39;</span>;</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;  }</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;  <span class="keywordflow">if</span> (array_key_exists(<span class="stringliteral">&#39;default&#39;</span>, $attributes)) {</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;    <span class="keywordflow">if</span> (!isset($attributes[<span class="stringliteral">&#39;default&#39;</span>])) {</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;      $default_val = <span class="stringliteral">&#39;NULL&#39;</span>;</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;      $default = <span class="stringliteral">&#39;default NULL&#39;</span>;</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;    }</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;    elseif ($attributes[<span class="stringliteral">&#39;default&#39;</span>] === FALSE) {</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;      $default = <span class="stringliteral">&#39;&#39;</span>;</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;    }</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;      $default_val = <span class="stringliteral">&quot;$attributes[default]&quot;</span>;</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;      $default = <span class="stringliteral">&quot;default $attributes[default]&quot;</span>;</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;</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;  $ret[] = update_sql(<span class="stringliteral">&quot;ALTER TABLE {&quot;</span>. $table .<span class="stringliteral">&quot;} ADD $column $type&quot;</span>);</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;  <span class="keywordflow">if</span> (!empty($default)) {</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;    $ret[] = update_sql(<span class="stringliteral">&quot;ALTER TABLE {&quot;</span>. $table .<span class="stringliteral">&quot;} ALTER $column SET $default&quot;</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;  <span class="keywordflow">if</span> (!empty($not_null)) {</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;    <span class="keywordflow">if</span> (!empty($default)) {</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;      $ret[] = update_sql(<span class="stringliteral">&quot;UPDATE {&quot;</span>. $table .<span class="stringliteral">&quot;} SET $column = $default_val&quot;</span>);</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;    }</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    $ret[] = update_sql(<span class="stringliteral">&quot;ALTER TABLE {&quot;</span>. $table .<span class="stringliteral">&quot;} ALTER $column SET NOT NULL&quot;</span>);</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;}</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;<span class="comment"> * Change a column definition using syntax appropriate for PostgreSQL.</span></div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;<span class="comment"> * Save result of SQL commands in $ret array.</span></div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;<span class="comment"> * Remember that changing a column definition involves adding a new column</span></div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;<span class="comment"> * and dropping an old one. This means that any indices, primary keys and</span></div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;<span class="comment"> * sequences from serial-type columns are dropped and might need to be</span></div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;<span class="comment"> * recreated.</span></div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;<span class="comment"> * @param $ret</span></div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;<span class="comment"> *   Array to which results will be added.</span></div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;<span class="comment"> * @param $table</span></div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;<span class="comment"> *   Name of the table, without {}</span></div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;<span class="comment"> * @param $column</span></div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;<span class="comment"> *   Name of the column to change</span></div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;<span class="comment"> * @param $column_new</span></div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;<span class="comment"> *   New name for the column (set to the same as $column if you don&#39;t want to change the name)</span></div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;<span class="comment"> * @param $type</span></div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;<span class="comment"> *   Type of column</span></div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;<span class="comment"> * @param $attributes</span></div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;<span class="comment"> *   Additional optional attributes. Recognized attributes:</span></div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;<span class="comment"> *     not null =&gt; TRUE|FALSE</span></div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;<span class="comment"> *     default  =&gt; NULL|FALSE|value (with or without &#39;&#39;, it won&#39;t be added)</span></div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;<span class="comment"> * @return</span></div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;<span class="comment"> *   nothing, but modifies $ret parameter.</span></div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00098"></a><span class="lineno"><a class="code" href="update__6_8inc.html#af6bd7fe55aa398bb18266c56be8bf97b">   98</a></span>&#160;<span class="keyword">function</span> <a class="code" href="update__6_8inc.html#af6bd7fe55aa398bb18266c56be8bf97b">db_change_column</a>(&amp;$ret, $table, $column, $column_new, $type, $attributes = array()) {</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;  <span class="keywordflow">if</span> (array_key_exists(<span class="stringliteral">&#39;not null&#39;</span>, $attributes) and $attributes[<span class="stringliteral">&#39;not null&#39;</span>]) {</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;    $not_null = <span class="stringliteral">&#39;NOT NULL&#39;</span>;</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> (array_key_exists(<span class="stringliteral">&#39;default&#39;</span>, $attributes)) {</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;    <span class="keywordflow">if</span> (!isset($attributes[<span class="stringliteral">&#39;default&#39;</span>])) {</div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;      $default_val = <span class="stringliteral">&#39;NULL&#39;</span>;</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;      $default = <span class="stringliteral">&#39;default NULL&#39;</span>;</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;    }</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;    elseif ($attributes[<span class="stringliteral">&#39;default&#39;</span>] === FALSE) {</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;      $default = <span class="stringliteral">&#39;&#39;</span>;</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">else</span> {</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;      $default_val = <span class="stringliteral">&quot;$attributes[default]&quot;</span>;</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;      $default = <span class="stringliteral">&quot;default $attributes[default]&quot;</span>;</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;</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;  $ret[] = update_sql(<span class="stringliteral">&quot;ALTER TABLE {&quot;</span>. $table .<span class="stringliteral">&quot;} RENAME $column TO &quot;</span>. $column .<span class="stringliteral">&quot;_old&quot;</span>);</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;  $ret[] = update_sql(<span class="stringliteral">&quot;ALTER TABLE {&quot;</span>. $table .<span class="stringliteral">&quot;} ADD $column_new $type&quot;</span>);</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;  $ret[] = update_sql(<span class="stringliteral">&quot;UPDATE {&quot;</span>. $table .<span class="stringliteral">&quot;} SET $column_new = &quot;</span>. $column .<span class="stringliteral">&quot;_old&quot;</span>);</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;  <span class="keywordflow">if</span> ($default) { $ret[] = update_sql(<span class="stringliteral">&quot;ALTER TABLE {&quot;</span>. $table .<span class="stringliteral">&quot;} ALTER $column_new SET $default&quot;</span>); }</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;  <span class="keywordflow">if</span> ($not_null) { $ret[] = update_sql(<span class="stringliteral">&quot;ALTER TABLE {&quot;</span>. $table .<span class="stringliteral">&quot;} ALTER $column_new SET NOT NULL&quot;</span>); }</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;  $ret[] = update_sql(<span class="stringliteral">&quot;ALTER TABLE {&quot;</span>. $table .<span class="stringliteral">&quot;} DROP &quot;</span>. $column .<span class="stringliteral">&quot;_old&quot;</span>);</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;}</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;<span class="comment"></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">  126</span>&#160;<span class="comment"> * Disable anything in the {system} table that is not compatible with the</span></div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;<span class="comment"> * current version of Drupal core.</span></div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00129"></a><span class="lineno"><a class="code" href="update__6_8inc.html#ab86cb0f00b89fc52f7f6294be9a1e33c">  129</a></span>&#160;<span class="keyword">function</span> <a class="code" href="update__6_8inc.html#ab86cb0f00b89fc52f7f6294be9a1e33c">update_fix_compatibility</a>() {</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;  $ret = array();</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;  $incompatible = array();</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;  $query = db_query(<span class="stringliteral">&quot;SELECT name, type, status FROM {system} WHERE status = 1 AND type IN (&#39;module&#39;,&#39;theme&#39;)&quot;</span>);</div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;  <span class="keywordflow">while</span> ($result = db_fetch_object($query)) {</div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;    <span class="keywordflow">if</span> (<a class="code" href="update__6_8inc.html#a39592132a77fd791c44a8d6faf362cb0">update_check_incompatibility</a>($result-&gt;name, $result-&gt;type)) {</div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;      $incompatible[] = $result-&gt;name;</div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;      <a class="code" href="group__logging.html#ga2a8afad8eafb1382e24a5601bc962e71">drush_log</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&quot;!type !name is incompatible with this release of Drupal, and will be disabled.&quot;</span>,</div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;        array(<span class="stringliteral">&quot;!type&quot;</span> =&gt; $result-&gt;type, <span class="stringliteral">&#39;!name&#39;</span> =&gt; $result-&gt;name)), LogLevel::WARNING);</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;  }</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;  <span class="keywordflow">if</span> (!empty($incompatible)) {</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;</div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;    $ret[] = update_sql(<span class="stringliteral">&quot;UPDATE {system} SET status = 0 WHERE name IN (&#39;&quot;</span>. implode(<span class="stringliteral">&quot;&#39;,&#39;&quot;</span>, $incompatible) .<span class="stringliteral">&quot;&#39;)&quot;</span>);</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> $ret;</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;<span class="comment"></span></div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;<span class="comment"> * Helper function to test compatibility of a module or theme.</span></div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00150"></a><span class="lineno"><a class="code" href="update__6_8inc.html#a39592132a77fd791c44a8d6faf362cb0">  150</a></span>&#160;<span class="keyword">function</span> <a class="code" href="update__6_8inc.html#a39592132a77fd791c44a8d6faf362cb0">update_check_incompatibility</a>($name, $type = <span class="stringliteral">&#39;module&#39;</span>) {</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;  <span class="keyword">static</span> $themes, $modules;</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">// Store values of expensive functions for future use.</span></div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;  <span class="keywordflow">if</span> (empty($themes) || empty($modules)) {</div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;    <a class="code" href="engines_8inc.html#a92390a2dd40c8ed5190be4af058813a8">drush_include_engine</a>(<span class="stringliteral">&#39;drupal&#39;</span>, <span class="stringliteral">&#39;environment&#39;</span>);</div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;    $themes = _system_theme_data();</div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;    $modules = module_rebuild_cache();</div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;  }</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;  <span class="keywordflow">if</span> ($type == <span class="stringliteral">&#39;module&#39;</span> &amp;&amp; isset($modules[$name])) {</div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;    $file = $modules[$name];</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> <span class="keywordflow">if</span> ($type == <span class="stringliteral">&#39;theme&#39;</span> &amp;&amp; isset($themes[$name])) {</div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;    $file = $themes[$name];</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;  <span class="keywordflow">if</span> (!isset($file)</div>
<div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;      || !isset($file-&gt;info[<span class="stringliteral">&#39;core&#39;</span>])</div>
<div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;      || $file-&gt;info[<span class="stringliteral">&#39;core&#39;</span>] != <a class="code" href="includes_2environment_8inc.html#a02b3e67cdaf5abc38c32b207ba2aee60">drush_get_drupal_core_compatibility</a>()</div>
<div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;      || version_compare(phpversion(), $file-&gt;info[<span class="stringliteral">&#39;php&#39;</span>]) &lt; 0) {</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;    <span class="keywordflow">return</span> TRUE;</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;  }</div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;  <span class="keywordflow">return</span> FALSE;</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"></span></div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;<span class="comment"> * Perform Drupal 5.x to 6.x updates that are required for update.php</span></div>
<div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;<span class="comment"> * to function properly.</span></div>
<div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;<span class="comment"> * This function runs when update.php is run the first time for 6.x,</span></div>
<div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;<span class="comment"> * even before updates are selected or performed.  It is important</span></div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;<span class="comment"> * that if updates are not ultimately performed that no changes are</span></div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;<span class="comment"> * made which make it impossible to continue using the prior version.</span></div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;<span class="comment"> * Just adding columns is safe.  However, renaming the</span></div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;<span class="comment"> * system.description column to owner is not.  Therefore, we add the</span></div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;<span class="comment"> * system.owner column and leave it to system_update_6008() to copy</span></div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;<span class="comment"> * the data from description and remove description. The same for</span></div>
<div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;<span class="comment"> * renaming locales_target.locale to locales_target.language, which</span></div>
<div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;<span class="comment"> * will be finished by locale_update_6002().</span></div>
<div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00190"></a><span class="lineno"><a class="code" href="update__6_8inc.html#af9abb57ca11fefe877843be4211307c4">  190</a></span>&#160;<span class="keyword">function</span> <a class="code" href="update__6_8inc.html#af9abb57ca11fefe877843be4211307c4">update_fix_d6_requirements</a>() {</div>
<div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;  $ret = array();</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="keywordflow">if</span> (drupal_get_installed_schema_version(<span class="stringliteral">&#39;system&#39;</span>) &lt; 6000 &amp;&amp; !variable_get(<span class="stringliteral">&#39;update_d6_requirements&#39;</span>, FALSE)) {</div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;    $spec = array(<span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;int&#39;</span>, <span class="stringliteral">&#39;size&#39;</span> =&gt; <span class="stringliteral">&#39;small&#39;</span>, <span class="stringliteral">&#39;default&#39;</span> =&gt; 0, <span class="stringliteral">&#39;not null&#39;</span> =&gt; TRUE);</div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;    db_add_field($ret, <span class="stringliteral">&#39;cache&#39;</span>, <span class="stringliteral">&#39;serialized&#39;</span>, $spec);</div>
<div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;    db_add_field($ret, <span class="stringliteral">&#39;cache_filter&#39;</span>, <span class="stringliteral">&#39;serialized&#39;</span>, $spec);</div>
<div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;    db_add_field($ret, <span class="stringliteral">&#39;cache_page&#39;</span>, <span class="stringliteral">&#39;serialized&#39;</span>, $spec);</div>
<div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;    db_add_field($ret, <span class="stringliteral">&#39;cache_menu&#39;</span>, <span class="stringliteral">&#39;serialized&#39;</span>, $spec);</div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;</div>
<div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;    db_add_field($ret, <span class="stringliteral">&#39;system&#39;</span>, <span class="stringliteral">&#39;info&#39;</span>, array(<span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;text&#39;</span>));</div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;    db_add_field($ret, <span class="stringliteral">&#39;system&#39;</span>, <span class="stringliteral">&#39;owner&#39;</span>, array(<span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;varchar&#39;</span>, <span class="stringliteral">&#39;length&#39;</span> =&gt; 255, <span class="stringliteral">&#39;not null&#39;</span> =&gt; TRUE, <span class="stringliteral">&#39;default&#39;</span> =&gt; <span class="stringliteral">&#39;&#39;</span>));</div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;    <span class="keywordflow">if</span> (db_table_exists(<span class="stringliteral">&#39;locales_target&#39;</span>)) {</div>
<div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;      db_add_field($ret, <span class="stringliteral">&#39;locales_target&#39;</span>, <span class="stringliteral">&#39;language&#39;</span>, array(<span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;varchar&#39;</span>, <span class="stringliteral">&#39;length&#39;</span> =&gt; 12, <span class="stringliteral">&#39;not null&#39;</span> =&gt; TRUE, <span class="stringliteral">&#39;default&#39;</span> =&gt; <span class="stringliteral">&#39;&#39;</span>));</div>
<div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;    }</div>
<div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;    <span class="keywordflow">if</span> (db_table_exists(<span class="stringliteral">&#39;locales_source&#39;</span>)) {</div>
<div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;      db_add_field($ret, <span class="stringliteral">&#39;locales_source&#39;</span>, <span class="stringliteral">&#39;textgroup&#39;</span>, array(<span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;varchar&#39;</span>, <span class="stringliteral">&#39;length&#39;</span> =&gt; 255, <span class="stringliteral">&#39;not null&#39;</span> =&gt; TRUE, <span class="stringliteral">&#39;default&#39;</span> =&gt; <span class="stringliteral">&#39;default&#39;</span>));</div>
<div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;      db_add_field($ret, <span class="stringliteral">&#39;locales_source&#39;</span>, <span class="stringliteral">&#39;version&#39;</span>, array(<span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;varchar&#39;</span>, <span class="stringliteral">&#39;length&#39;</span> =&gt; 20, <span class="stringliteral">&#39;not null&#39;</span> =&gt; TRUE, <span class="stringliteral">&#39;default&#39;</span> =&gt; <span class="stringliteral">&#39;none&#39;</span>));</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;    variable_set(<span class="stringliteral">&#39;update_d6_requirements&#39;</span>, TRUE);</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;    <span class="comment">// Create the cache_block table. See system_update_6027() for more details.</span></div>
<div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;    $schema[<span class="stringliteral">&#39;cache_block&#39;</span>] = array(</div>
<div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;      <span class="stringliteral">&#39;fields&#39;</span> =&gt; array(</div>
<div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;        <span class="stringliteral">&#39;cid&#39;</span>        =&gt; array(<span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;varchar&#39;</span>, <span class="stringliteral">&#39;length&#39;</span> =&gt; 255, <span class="stringliteral">&#39;not null&#39;</span> =&gt; TRUE, <span class="stringliteral">&#39;default&#39;</span> =&gt; <span class="stringliteral">&#39;&#39;</span>),</div>
<div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;        <span class="stringliteral">&#39;data&#39;</span>       =&gt; array(<span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;blob&#39;</span>, <span class="stringliteral">&#39;not null&#39;</span> =&gt; FALSE, <span class="stringliteral">&#39;size&#39;</span> =&gt; <span class="stringliteral">&#39;big&#39;</span>),</div>
<div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;        <span class="stringliteral">&#39;expire&#39;</span>     =&gt; array(<span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;int&#39;</span>, <span class="stringliteral">&#39;not null&#39;</span> =&gt; TRUE, <span class="stringliteral">&#39;default&#39;</span> =&gt; 0),</div>
<div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;        <span class="stringliteral">&#39;created&#39;</span>    =&gt; array(<span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;int&#39;</span>, <span class="stringliteral">&#39;not null&#39;</span> =&gt; TRUE, <span class="stringliteral">&#39;default&#39;</span> =&gt; 0),</div>
<div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;        <span class="stringliteral">&#39;headers&#39;</span>    =&gt; array(<span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;text&#39;</span>, <span class="stringliteral">&#39;not null&#39;</span> =&gt; FALSE),</div>
<div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;        <span class="stringliteral">&#39;serialized&#39;</span> =&gt; array(<span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;int&#39;</span>, <span class="stringliteral">&#39;size&#39;</span> =&gt; <span class="stringliteral">&#39;small&#39;</span>, <span class="stringliteral">&#39;not null&#39;</span> =&gt; TRUE, <span class="stringliteral">&#39;default&#39;</span> =&gt; 0)</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="stringliteral">&#39;indexes&#39;</span> =&gt; array(<span class="stringliteral">&#39;expire&#39;</span> =&gt; array(<span class="stringliteral">&#39;expire&#39;</span>)),</div>
<div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160;      <span class="stringliteral">&#39;primary key&#39;</span> =&gt; array(<span class="stringliteral">&#39;cid&#39;</span>),</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;    db_create_table($ret, <span class="stringliteral">&#39;cache_block&#39;</span>, $schema[<span class="stringliteral">&#39;cache_block&#39;</span>]);</div>
<div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;</div>
<div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;    <span class="comment">// Create the semaphore table now -- the menu system after 6.15 depends on</span></div>
<div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;    <span class="comment">// this table, and menu code runs in updates prior to the table being</span></div>
<div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;    <span class="comment">// created in its original update function, system_update_6054().</span></div>
<div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;    $schema[<span class="stringliteral">&#39;semaphore&#39;</span>] = array(</div>
<div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;      <span class="stringliteral">&#39;fields&#39;</span> =&gt; array(</div>
<div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;        <span class="stringliteral">&#39;name&#39;</span> =&gt; array(</div>
<div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;        <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;varchar&#39;</span>,</div>
<div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;        <span class="stringliteral">&#39;length&#39;</span> =&gt; 255,</div>
<div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160;        <span class="stringliteral">&#39;not null&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00235"></a><span class="lineno">  235</span>&#160;        <span class="stringliteral">&#39;default&#39;</span> =&gt; <span class="stringliteral">&#39;&#39;</span>),</div>
<div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160;      <span class="stringliteral">&#39;value&#39;</span> =&gt; array(</div>
<div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;        <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;varchar&#39;</span>,</div>
<div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;        <span class="stringliteral">&#39;length&#39;</span> =&gt; 255,</div>
<div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160;        <span class="stringliteral">&#39;not null&#39;</span> =&gt; TRUE,</div>
<div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;        <span class="stringliteral">&#39;default&#39;</span> =&gt; <span class="stringliteral">&#39;&#39;</span>),</div>
<div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;      <span class="stringliteral">&#39;expire&#39;</span> =&gt; array(</div>
<div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;        <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;float&#39;</span>,</div>
<div class="line"><a name="l00243"></a><span class="lineno">  243</span>&#160;        <span class="stringliteral">&#39;size&#39;</span> =&gt; <span class="stringliteral">&#39;big&#39;</span>,</div>
<div class="line"><a name="l00244"></a><span class="lineno">  244</span>&#160;        <span class="stringliteral">&#39;not null&#39;</span> =&gt; TRUE),</div>
<div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160;      ),</div>
<div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160;     <span class="stringliteral">&#39;indexes&#39;</span> =&gt; array(<span class="stringliteral">&#39;expire&#39;</span> =&gt; array(<span class="stringliteral">&#39;expire&#39;</span>)),</div>
<div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;     <span class="stringliteral">&#39;primary key&#39;</span> =&gt; array(<span class="stringliteral">&#39;name&#39;</span>),</div>
<div class="line"><a name="l00248"></a><span class="lineno">  248</span>&#160;    );</div>
<div class="line"><a name="l00249"></a><span class="lineno">  249</span>&#160;    db_create_table($ret, <span class="stringliteral">&#39;semaphore&#39;</span>, $schema[<span class="stringliteral">&#39;semaphore&#39;</span>]);</div>
<div class="line"><a name="l00250"></a><span class="lineno">  250</span>&#160;  }</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">return</span> $ret;</div>
<div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;}</div>
<div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;<span class="comment"> * Check update requirements and report any errors.</span></div>
<div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00258"></a><span class="lineno"><a class="code" href="update__6_8inc.html#ad0b8cf7510033800502402c275add53b">  258</a></span>&#160;<span class="keyword">function</span> <a class="code" href="update__6_8inc.html#ad0b8cf7510033800502402c275add53b">update_check_requirements</a>() {</div>
<div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;  <span class="comment">// Check the system module requirements only.</span></div>
<div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160;  $requirements = module_invoke(<span class="stringliteral">&#39;system&#39;</span>, <span class="stringliteral">&#39;requirements&#39;</span>, <span class="stringliteral">&#39;update&#39;</span>);</div>
<div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;  $severity = drupal_requirements_severity($requirements);</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;  <span class="comment">// If there are issues, report them.</span></div>
<div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;  <span class="keywordflow">if</span> ($severity != REQUIREMENT_OK) {</div>
<div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160;    <span class="keywordflow">foreach</span> ($requirements as $requirement) {</div>
<div class="line"><a name="l00266"></a><span class="lineno">  266</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>] != REQUIREMENT_OK) {</div>
<div class="line"><a name="l00267"></a><span class="lineno">  267</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="l00268"></a><span class="lineno">  268</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="l00269"></a><span class="lineno">  269</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="l00270"></a><span class="lineno">  270</span>&#160;        }</div>
<div class="line"><a name="l00271"></a><span class="lineno">  271</span>&#160;        <a class="code" href="group__logging.html#ga2a8afad8eafb1382e24a5601bc962e71">drush_log</a>($message, LogLevel::WARNING);</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;    }</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;}</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">/**</span></div>
<div class="line"><a name="l00278"></a><span class="lineno">  278</span>&#160;<span class="comment"> * Create the batch table.</span></div>
<div class="line"><a name="l00279"></a><span class="lineno">  279</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00280"></a><span class="lineno">  280</span>&#160;<span class="comment"> * This is part of the Drupal 5.x to 6.x migration.</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__6_8inc.html#a123fb38f4b7623d8ee5948c0d2e748eb">  282</a></span>&#160;<span class="keyword">function</span> <a class="code" href="update__6_8inc.html#a123fb38f4b7623d8ee5948c0d2e748eb">update_create_batch_table</a>() {</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="comment">// If batch table exists, update is not necessary</span></div>
<div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;  <span class="keywordflow">if</span> (db_table_exists(<span class="stringliteral">&#39;batch&#39;</span>)) {</div>
<div class="line"><a name="l00286"></a><span class="lineno">  286</span>&#160;    <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l00287"></a><span class="lineno">  287</span>&#160;  }</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;  $schema[<span class="stringliteral">&#39;batch&#39;</span>] = array(</div>
<div class="line"><a name="l00290"></a><span class="lineno">  290</span>&#160;    <span class="stringliteral">&#39;fields&#39;</span> =&gt; array(</div>
<div class="line"><a name="l00291"></a><span class="lineno">  291</span>&#160;      <span class="stringliteral">&#39;bid&#39;</span>       =&gt; array(<span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;serial&#39;</span>, <span class="stringliteral">&#39;unsigned&#39;</span> =&gt; TRUE, <span class="stringliteral">&#39;not null&#39;</span> =&gt; TRUE),</div>
<div class="line"><a name="l00292"></a><span class="lineno">  292</span>&#160;      <span class="stringliteral">&#39;token&#39;</span>     =&gt; array(<span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;varchar&#39;</span>, <span class="stringliteral">&#39;length&#39;</span> =&gt; 64, <span class="stringliteral">&#39;not null&#39;</span> =&gt; TRUE),</div>
<div class="line"><a name="l00293"></a><span class="lineno">  293</span>&#160;      <span class="stringliteral">&#39;timestamp&#39;</span> =&gt; array(<span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;int&#39;</span>, <span class="stringliteral">&#39;not null&#39;</span> =&gt; TRUE),</div>
<div class="line"><a name="l00294"></a><span class="lineno">  294</span>&#160;      <span class="stringliteral">&#39;batch&#39;</span>     =&gt; array(<span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;text&#39;</span>, <span class="stringliteral">&#39;not null&#39;</span> =&gt; FALSE, <span class="stringliteral">&#39;size&#39;</span> =&gt; <span class="stringliteral">&#39;big&#39;</span>)</div>
<div class="line"><a name="l00295"></a><span class="lineno">  295</span>&#160;    ),</div>
<div class="line"><a name="l00296"></a><span class="lineno">  296</span>&#160;    <span class="stringliteral">&#39;primary key&#39;</span> =&gt; array(<span class="stringliteral">&#39;bid&#39;</span>),</div>
<div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;    <span class="stringliteral">&#39;indexes&#39;</span> =&gt; array(<span class="stringliteral">&#39;token&#39;</span> =&gt; array(<span class="stringliteral">&#39;token&#39;</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;  $ret = array();</div>
<div class="line"><a name="l00301"></a><span class="lineno">  301</span>&#160;  db_create_table($ret, <span class="stringliteral">&#39;batch&#39;</span>, $schema[<span class="stringliteral">&#39;batch&#39;</span>]);</div>
<div class="line"><a name="l00302"></a><span class="lineno">  302</span>&#160;  <span class="keywordflow">return</span> $ret;</div>
<div class="line"><a name="l00303"></a><span class="lineno">  303</span>&#160;}</div>
<div class="line"><a name="l00304"></a><span class="lineno">  304</span>&#160;</div>
<div class="line"><a name="l00305"></a><span class="lineno">  305</span>&#160;<span class="keyword">function</span> update_main_prepare() {</div>
<div class="line"><a name="l00306"></a><span class="lineno">  306</span>&#160;  global $profile;</div>
<div class="line"><a name="l00307"></a><span class="lineno">  307</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="l00308"></a><span class="lineno">  308</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="l00309"></a><span class="lineno">  309</span>&#160;  <a class="code" href="group__errorhandling.html#ga4d3fc14a9eef57a06ac4bab523744462">drush_errors_off</a>();</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;  require_once <span class="stringliteral">&#39;./includes/bootstrap.inc&#39;</span>;</div>
<div class="line"><a name="l00312"></a><span class="lineno">  312</span>&#160;  <span class="comment">// Minimum load of components.</span></div>
<div class="line"><a name="l00313"></a><span class="lineno">  313</span>&#160;  <span class="comment">// This differs from the Drupal 6 update.php workflow for compatbility with</span></div>
<div class="line"><a name="l00314"></a><span class="lineno">  314</span>&#160;  <span class="comment">// the Drupal 6 backport of module_implements() caching.</span></div>
<div class="line"><a name="l00315"></a><span class="lineno">  315</span>&#160;  <span class="comment">// @see http://drupal.org/node/557542</span></div>
<div class="line"><a name="l00316"></a><span class="lineno">  316</span>&#160;  drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_DATABASE);</div>
<div class="line"><a name="l00317"></a><span class="lineno">  317</span>&#160;  require_once <span class="stringliteral">&#39;./includes/install.inc&#39;</span>;</div>
<div class="line"><a name="l00318"></a><span class="lineno">  318</span>&#160;  require_once <span class="stringliteral">&#39;./includes/file.inc&#39;</span>;</div>
<div class="line"><a name="l00319"></a><span class="lineno">  319</span>&#160;  require_once <span class="stringliteral">&#39;./modules/system/system.install&#39;</span>;</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;  <span class="comment">// Load module basics.</span></div>
<div class="line"><a name="l00322"></a><span class="lineno">  322</span>&#160;  include_once <span class="stringliteral">&#39;./includes/module.inc&#39;</span>;</div>
<div class="line"><a name="l00323"></a><span class="lineno">  323</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="l00324"></a><span class="lineno">  324</span>&#160;  $module_list[<span class="stringliteral">&#39;filter&#39;</span>][<span class="stringliteral">&#39;filename&#39;</span>] = <span class="stringliteral">&#39;modules/filter/filter.module&#39;</span>;</div>
<div class="line"><a name="l00325"></a><span class="lineno">  325</span>&#160;  module_list(TRUE, FALSE, FALSE, $module_list);</div>
<div class="line"><a name="l00326"></a><span class="lineno">  326</span>&#160;  module_implements(<span class="stringliteral">&#39;&#39;</span>, FALSE, TRUE);</div>
<div class="line"><a name="l00327"></a><span class="lineno">  327</span>&#160;</div>
<div class="line"><a name="l00328"></a><span class="lineno">  328</span>&#160;  drupal_load(<span class="stringliteral">&#39;module&#39;</span>, <span class="stringliteral">&#39;system&#39;</span>);</div>
<div class="line"><a name="l00329"></a><span class="lineno">  329</span>&#160;  drupal_load(<span class="stringliteral">&#39;module&#39;</span>, <span class="stringliteral">&#39;filter&#39;</span>);</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">// Set up $language, since the installer components require it.</span></div>
<div class="line"><a name="l00332"></a><span class="lineno">  332</span>&#160;  drupal_init_language();</div>
<div class="line"><a name="l00333"></a><span class="lineno">  333</span>&#160;</div>
<div class="line"><a name="l00334"></a><span class="lineno">  334</span>&#160;  <span class="comment">// Set up theme system for the maintenance page.</span></div>
<div class="line"><a name="l00335"></a><span class="lineno">  335</span>&#160;  drupal_maintenance_theme();</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;  <span class="comment">// Check the update requirements for Drupal.</span></div>
<div class="line"><a name="l00338"></a><span class="lineno">  338</span>&#160;  <a class="code" href="update__6_8inc.html#ad0b8cf7510033800502402c275add53b">update_check_requirements</a>();</div>
<div class="line"><a name="l00339"></a><span class="lineno">  339</span>&#160;</div>
<div class="line"><a name="l00340"></a><span class="lineno">  340</span>&#160;  drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);</div>
<div class="line"><a name="l00341"></a><span class="lineno">  341</span>&#160;  $profile = variable_get(<span class="stringliteral">&#39;install_profile&#39;</span>, <span class="stringliteral">&#39;default&#39;</span>);</div>
<div class="line"><a name="l00342"></a><span class="lineno">  342</span>&#160;  <span class="comment">// Updates only run reliably if user ID #1 is logged in. For example, node_delete() requires elevated perms in D5/6.</span></div>
<div class="line"><a name="l00343"></a><span class="lineno">  343</span>&#160;  <span class="keywordflow">if</span> (!<a class="code" href="context_8inc.html#ad25559f8d7d753f636fbeac347c29fc5">drush_get_context</a>(<span class="stringliteral">&#39;DRUSH_USER&#39;</span>)) {</div>
<div class="line"><a name="l00344"></a><span class="lineno">  344</span>&#160;    <a class="code" href="context_8inc.html#aa4b55e2f6174c8b6efaa8f23a0f9e0af">drush_set_option</a>(<span class="stringliteral">&#39;user&#39;</span>, 1);</div>
<div class="line"><a name="l00345"></a><span class="lineno">  345</span>&#160;    drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_LOGIN);</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;</div>
<div class="line"><a name="l00348"></a><span class="lineno">  348</span>&#160;  <span class="comment">// This must happen *after* drupal_bootstrap(), since it calls</span></div>
<div class="line"><a name="l00349"></a><span class="lineno">  349</span>&#160;  <span class="comment">// variable_(get|set), which only works after a full bootstrap.</span></div>
<div class="line"><a name="l00350"></a><span class="lineno">  350</span>&#160;  <a class="code" href="drupal_8inc.html#abc6906957148e12e75f22aec44c45ec9">_drush_log_update_sql</a>(<a class="code" href="update__6_8inc.html#a123fb38f4b7623d8ee5948c0d2e748eb">update_create_batch_table</a>());</div>
<div class="line"><a name="l00351"></a><span class="lineno">  351</span>&#160;</div>
<div class="line"><a name="l00352"></a><span class="lineno">  352</span>&#160;  <span class="comment">// Turn error reporting back on. From now on, only fatal errors (which are</span></div>
<div class="line"><a name="l00353"></a><span class="lineno">  353</span>&#160;  <span class="comment">// not passed through the error handler) will cause a message to be printed.</span></div>
<div class="line"><a name="l00354"></a><span class="lineno">  354</span>&#160;  <a class="code" href="group__errorhandling.html#ga303bcdf8b73c31b19ba4de4f2f6ef41b">drush_errors_on</a>();</div>
<div class="line"><a name="l00355"></a><span class="lineno">  355</span>&#160;</div>
<div class="line"><a name="l00356"></a><span class="lineno">  356</span>&#160;  <span class="comment">// Perform Drupal 5.x to 6.x updates that are required for update.php to function properly.</span></div>
<div class="line"><a name="l00357"></a><span class="lineno">  357</span>&#160;  <a class="code" href="drupal_8inc.html#abc6906957148e12e75f22aec44c45ec9">_drush_log_update_sql</a>(<a class="code" href="update__6_8inc.html#af9abb57ca11fefe877843be4211307c4">update_fix_d6_requirements</a>());</div>
<div class="line"><a name="l00358"></a><span class="lineno">  358</span>&#160;</div>
<div class="line"><a name="l00359"></a><span class="lineno">  359</span>&#160;  <span class="comment">// Must unset $theme-&gt;status in order to safely rescan and repopulate</span></div>
<div class="line"><a name="l00360"></a><span class="lineno">  360</span>&#160;  <span class="comment">// the system table to ensure we have a full picture of the platform.</span></div>
<div class="line"><a name="l00361"></a><span class="lineno">  361</span>&#160;  <span class="comment">// This is needed because $theme-&gt;status is set to 0 in a call to</span></div>
<div class="line"><a name="l00362"></a><span class="lineno">  362</span>&#160;  <span class="comment">// list_themes() done by drupal_maintenance_theme().</span></div>
<div class="line"><a name="l00363"></a><span class="lineno">  363</span>&#160;  <span class="comment">// It is a issue with _system_theme_data() that returns its own cache</span></div>
<div class="line"><a name="l00364"></a><span class="lineno">  364</span>&#160;  <span class="comment">// variable and can be modififed by others. When this is fixed in</span></div>
<div class="line"><a name="l00365"></a><span class="lineno">  365</span>&#160;  <span class="comment">// drupal core we can remove this unset.</span></div>
<div class="line"><a name="l00366"></a><span class="lineno">  366</span>&#160;  <span class="comment">// For reference see: http://drupal.org/node/762754</span></div>
<div class="line"><a name="l00367"></a><span class="lineno">  367</span>&#160;  $themes = _system_theme_data();</div>
<div class="line"><a name="l00368"></a><span class="lineno">  368</span>&#160;  <span class="keywordflow">foreach</span> ($themes as $theme) {</div>
<div class="line"><a name="l00369"></a><span class="lineno">  369</span>&#160;    unset($theme-&gt;status);</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;  <a class="code" href="includes_2environment_8inc.html#a2f6ea049bc3f5361815aafe6f44a535d">drush_get_extensions</a>();</div>
<div class="line"><a name="l00372"></a><span class="lineno">  372</span>&#160;</div>
<div class="line"><a name="l00373"></a><span class="lineno">  373</span>&#160;  include_once <span class="stringliteral">&#39;./includes/batch.inc&#39;</span>;</div>
<div class="line"><a name="l00374"></a><span class="lineno">  374</span>&#160;  drupal_load_updates();</div>
<div class="line"><a name="l00375"></a><span class="lineno">  375</span>&#160;</div>
<div class="line"><a name="l00376"></a><span class="lineno">  376</span>&#160;  <span class="comment">// Disable anything in the {system} table that is not compatible with the current version of Drupal core.</span></div>
<div class="line"><a name="l00377"></a><span class="lineno">  377</span>&#160;  <a class="code" href="drupal_8inc.html#abc6906957148e12e75f22aec44c45ec9">_drush_log_update_sql</a>(<a class="code" href="update__6_8inc.html#ab86cb0f00b89fc52f7f6294be9a1e33c">update_fix_compatibility</a>());</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;</div>
<div class="line"><a name="l00380"></a><span class="lineno">  380</span>&#160;<span class="keyword">function</span> update_main() {</div>
<div class="line"><a name="l00381"></a><span class="lineno">  381</span>&#160;  update_main_prepare();</div>
<div class="line"><a name="l00382"></a><span class="lineno">  382</span>&#160;</div>
<div class="line"><a name="l00383"></a><span class="lineno">  383</span>&#160;  list($pending, $start) = <a class="code" href="update_8inc.html#ad074fc63b51c042f4d752543db9ad0e6">updatedb_status</a>();</div>
<div class="line"><a name="l00384"></a><span class="lineno">  384</span>&#160;</div>
<div class="line"><a name="l00385"></a><span class="lineno">  385</span>&#160;  <span class="comment">// Print a list of pending updates for this module and get confirmation.</span></div>
<div class="line"><a name="l00386"></a><span class="lineno">  386</span>&#160;  <span class="keywordflow">if</span> ($pending) {</div>
<div class="line"><a name="l00387"></a><span class="lineno">  387</span>&#160;    <span class="comment">// @todo get table header working</span></div>
<div class="line"><a name="l00388"></a><span class="lineno">  388</span>&#160;    <span class="comment">// array_unshift($pending, array(dt(&#39;Module&#39;), dt(&#39;ID&#39;), dt(&#39;Description&#39;)));</span></div>
<div class="line"><a name="l00389"></a><span class="lineno">  389</span>&#160;    <a class="code" href="group__outputfunctions.html#ga2dfb80176f98c67097334acfa98211cd">drush_print_table</a>($pending, FALSE);</div>
<div class="line"><a name="l00390"></a><span class="lineno">  390</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="l00391"></a><span class="lineno">  391</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="l00392"></a><span class="lineno">  392</span>&#160;    }</div>
<div class="line"><a name="l00393"></a><span class="lineno">  393</span>&#160;    <span class="comment">// Proceed with running all pending updates.</span></div>
<div class="line"><a name="l00394"></a><span class="lineno">  394</span>&#160;    $operations = array();</div>
<div class="line"><a name="l00395"></a><span class="lineno">  395</span>&#160;    <span class="keywordflow">foreach</span> ($start as $module =&gt; $version) {</div>
<div class="line"><a name="l00396"></a><span class="lineno">  396</span>&#160;      drupal_set_installed_schema_version($module, $version - 1);</div>
<div class="line"><a name="l00397"></a><span class="lineno">  397</span>&#160;      $updates = drupal_get_schema_versions($module);</div>
<div class="line"><a name="l00398"></a><span class="lineno">  398</span>&#160;      $max_version = max($updates);</div>
<div class="line"><a name="l00399"></a><span class="lineno">  399</span>&#160;      <span class="keywordflow">if</span> ($version &lt;= $max_version) {</div>
<div class="line"><a name="l00400"></a><span class="lineno">  400</span>&#160;        <a class="code" href="group__logging.html#ga2a8afad8eafb1382e24a5601bc962e71">drush_log</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;Updating module @module from schema version @start to schema version @max&#39;</span>, array(<span class="stringliteral">&#39;@module&#39;</span> =&gt; $module, <span class="stringliteral">&#39;@start&#39;</span> =&gt; $version - 1, <span class="stringliteral">&#39;@max&#39;</span> =&gt; $max_version)));</div>
<div class="line"><a name="l00401"></a><span class="lineno">  401</span>&#160;        <span class="keywordflow">foreach</span> ($updates as $update) {</div>
<div class="line"><a name="l00402"></a><span class="lineno">  402</span>&#160;          <span class="keywordflow">if</span> ($update &gt;= $version) {</div>
<div class="line"><a name="l00403"></a><span class="lineno">  403</span>&#160;            $operations[] = array(<span class="stringliteral">&#39;_update_do_one&#39;</span>, array($module, $update));</div>
<div class="line"><a name="l00404"></a><span class="lineno">  404</span>&#160;          }</div>
<div class="line"><a name="l00405"></a><span class="lineno">  405</span>&#160;        }</div>
<div class="line"><a name="l00406"></a><span class="lineno">  406</span>&#160;      }</div>
<div class="line"><a name="l00407"></a><span class="lineno">  407</span>&#160;      <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00408"></a><span class="lineno">  408</span>&#160;        <a class="code" href="group__logging.html#ga2a8afad8eafb1382e24a5601bc962e71">drush_log</a>(<a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;No database updates for module @module&#39;</span>, array(<span class="stringliteral">&#39;@module&#39;</span> =&gt; $module)), LogLevel::SUCCESS);</div>
<div class="line"><a name="l00409"></a><span class="lineno">  409</span>&#160;      }</div>
<div class="line"><a name="l00410"></a><span class="lineno">  410</span>&#160;    }</div>
<div class="line"><a name="l00411"></a><span class="lineno">  411</span>&#160;    $batch = array(</div>
<div class="line"><a name="l00412"></a><span class="lineno">  412</span>&#160;      <span class="stringliteral">&#39;operations&#39;</span> =&gt; $operations,</div>
<div class="line"><a name="l00413"></a><span class="lineno">  413</span>&#160;      <span class="stringliteral">&#39;title&#39;</span> =&gt; <span class="stringliteral">&#39;Updating&#39;</span>,</div>
<div class="line"><a name="l00414"></a><span class="lineno">  414</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="l00415"></a><span class="lineno">  415</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="l00416"></a><span class="lineno">  416</span>&#160;      <span class="stringliteral">&#39;finished&#39;</span> =&gt; <span class="stringliteral">&#39;update_finished&#39;</span>,</div>
<div class="line"><a name="l00417"></a><span class="lineno">  417</span>&#160;    );</div>
<div class="line"><a name="l00418"></a><span class="lineno">  418</span>&#160;    batch_set($batch);</div>
<div class="line"><a name="l00419"></a><span class="lineno">  419</span>&#160;    $batch =&amp; batch_get();</div>
<div class="line"><a name="l00420"></a><span class="lineno">  420</span>&#160;    $batch[<span class="stringliteral">&#39;progressive&#39;</span>] = FALSE;</div>
<div class="line"><a name="l00421"></a><span class="lineno">  421</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="l00422"></a><span class="lineno">  422</span>&#160;  }</div>
<div class="line"><a name="l00423"></a><span class="lineno">  423</span>&#160;  <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00424"></a><span class="lineno">  424</span>&#160;    <a class="code" href="group__logging.html#ga2a8afad8eafb1382e24a5601bc962e71">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="l00425"></a><span class="lineno">  425</span>&#160;  }</div>
<div class="line"><a name="l00426"></a><span class="lineno">  426</span>&#160;</div>
<div class="line"><a name="l00427"></a><span class="lineno">  427</span>&#160;  <span class="keywordflow">return</span> count($pending);</div>
<div class="line"><a name="l00428"></a><span class="lineno">  428</span>&#160;}</div>
<div class="line"><a name="l00429"></a><span class="lineno">  429</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00430"></a><span class="lineno">  430</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00431"></a><span class="lineno">  431</span>&#160;<span class="comment"> * A simplified version of the batch_do_one function from update.php</span></div>
<div class="line"><a name="l00432"></a><span class="lineno">  432</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00433"></a><span class="lineno">  433</span>&#160;<span class="comment"> * This does not mess with sessions and the like, as it will be used</span></div>
<div class="line"><a name="l00434"></a><span class="lineno">  434</span>&#160;<span class="comment"> * from the command line</span></div>
<div class="line"><a name="l00435"></a><span class="lineno">  435</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00436"></a><span class="lineno"><a class="code" href="update__6_8inc.html#afc8cabc135ea5705d5fc503036c68678">  436</a></span>&#160;<span class="keyword">function</span> <a class="code" href="update__6_8inc.html#afc8cabc135ea5705d5fc503036c68678">_update_do_one</a>($module, $number, &amp;$context) {</div>
<div class="line"><a name="l00437"></a><span class="lineno">  437</span>&#160;  <span class="comment">// If updates for this module have been aborted</span></div>
<div class="line"><a name="l00438"></a><span class="lineno">  438</span>&#160;  <span class="comment">// in a previous step, go no further.</span></div>
<div class="line"><a name="l00439"></a><span class="lineno">  439</span>&#160;  <span class="keywordflow">if</span> (!empty($context[<span class="stringliteral">&#39;results&#39;</span>][$module][<span class="stringliteral">&#39;#abort&#39;</span>])) {</div>
<div class="line"><a name="l00440"></a><span class="lineno">  440</span>&#160;    <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l00441"></a><span class="lineno">  441</span>&#160;  }</div>
<div class="line"><a name="l00442"></a><span class="lineno">  442</span>&#160;</div>
<div class="line"><a name="l00443"></a><span class="lineno">  443</span>&#160;  $function = $module .<span class="stringliteral">&#39;_update_&#39;</span>. $number;</div>
<div class="line"><a name="l00444"></a><span class="lineno">  444</span>&#160;  <a class="code" href="group__logging.html#ga2a8afad8eafb1382e24a5601bc962e71">drush_log</a>(<span class="stringliteral">&quot;Executing $function&quot;</span>, LogLevel::SUCCESS);</div>
<div class="line"><a name="l00445"></a><span class="lineno">  445</span>&#160;</div>
<div class="line"><a name="l00446"></a><span class="lineno">  446</span>&#160;  <span class="keywordflow">if</span> (function_exists($function)) {</div>
<div class="line"><a name="l00447"></a><span class="lineno">  447</span>&#160;    $ret = $function($context[<span class="stringliteral">&#39;sandbox&#39;</span>]);</div>
<div class="line"><a name="l00448"></a><span class="lineno">  448</span>&#160;    $context[<span class="stringliteral">&#39;results&#39;</span>][$module] = $ret;</div>
<div class="line"><a name="l00449"></a><span class="lineno">  449</span>&#160;    <a class="code" href="drupal_8inc.html#abc6906957148e12e75f22aec44c45ec9">_drush_log_update_sql</a>($ret);</div>
<div class="line"><a name="l00450"></a><span class="lineno">  450</span>&#160;  }</div>
<div class="line"><a name="l00451"></a><span class="lineno">  451</span>&#160;</div>
<div class="line"><a name="l00452"></a><span class="lineno">  452</span>&#160;  <span class="keywordflow">if</span> (isset($ret[<span class="stringliteral">&#39;#finished&#39;</span>])) {</div>
<div class="line"><a name="l00453"></a><span class="lineno">  453</span>&#160;    $context[<span class="stringliteral">&#39;finished&#39;</span>] = $ret[<span class="stringliteral">&#39;#finished&#39;</span>];</div>
<div class="line"><a name="l00454"></a><span class="lineno">  454</span>&#160;    unset($ret[<span class="stringliteral">&#39;#finished&#39;</span>]);</div>
<div class="line"><a name="l00455"></a><span class="lineno">  455</span>&#160;  }</div>
<div class="line"><a name="l00456"></a><span class="lineno">  456</span>&#160;</div>
<div class="line"><a name="l00457"></a><span class="lineno">  457</span>&#160;  <span class="keywordflow">if</span> ($context[<span class="stringliteral">&#39;finished&#39;</span>] == 1 &amp;&amp; empty($context[<span class="stringliteral">&#39;results&#39;</span>][$module][<span class="stringliteral">&#39;#abort&#39;</span>])) {</div>
<div class="line"><a name="l00458"></a><span class="lineno">  458</span>&#160;    drupal_set_installed_schema_version($module, $number);</div>
<div class="line"><a name="l00459"></a><span class="lineno">  459</span>&#160;  }</div>
<div class="line"><a name="l00460"></a><span class="lineno">  460</span>&#160;</div>
<div class="line"><a name="l00461"></a><span class="lineno">  461</span>&#160;}</div>
<div class="line"><a name="l00462"></a><span class="lineno">  462</span>&#160;</div>
<div class="line"><a name="l00463"></a><span class="lineno">  463</span>&#160;<span class="keyword">function</span> _update_batch_command($id) {</div>
<div class="line"><a name="l00464"></a><span class="lineno">  464</span>&#160;  update_main_prepare();</div>
<div class="line"><a name="l00465"></a><span class="lineno">  465</span>&#160;  <a class="code" href="includes_2batch_8inc.html#af470f96043a86e75e72cb186abf518ce">drush_batch_command</a>($id);</div>
<div class="line"><a name="l00466"></a><span class="lineno">  466</span>&#160;}</div>
<div class="line"><a name="l00467"></a><span class="lineno">  467</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00468"></a><span class="lineno">  468</span>&#160;<span class="comment">/**</span></div>
<div class="line"><a name="l00469"></a><span class="lineno">  469</span>&#160;<span class="comment"> * Return a 2 item array with</span></div>
<div class="line"><a name="l00470"></a><span class="lineno">  470</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="l00471"></a><span class="lineno">  471</span>&#160;<span class="comment"> *  - an array listing the first update to run, keyed by module.</span></div>
<div class="line"><a name="l00472"></a><span class="lineno">  472</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00473"></a><span class="lineno"><a class="code" href="update__6_8inc.html#ad074fc63b51c042f4d752543db9ad0e6">  473</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="l00474"></a><span class="lineno">  474</span>&#160;  $return = array();</div>
<div class="line"><a name="l00475"></a><span class="lineno">  475</span>&#160;</div>
<div class="line"><a name="l00476"></a><span class="lineno">  476</span>&#160;  $modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE);</div>
<div class="line"><a name="l00477"></a><span class="lineno">  477</span>&#160;  <span class="keywordflow">foreach</span> ($modules as $module =&gt; $schema_version) {</div>
<div class="line"><a name="l00478"></a><span class="lineno">  478</span>&#160;    $updates = drupal_get_schema_versions($module);</div>
<div class="line"><a name="l00479"></a><span class="lineno">  479</span>&#160;    <span class="comment">// Skip incompatible module updates completely, otherwise test schema versions.</span></div>
<div class="line"><a name="l00480"></a><span class="lineno">  480</span>&#160;    <span class="keywordflow">if</span> (!<a class="code" href="update__6_8inc.html#a39592132a77fd791c44a8d6faf362cb0">update_check_incompatibility</a>($module) &amp;&amp; $updates !== FALSE &amp;&amp; $schema_version &gt;= 0) {</div>
<div class="line"><a name="l00481"></a><span class="lineno">  481</span>&#160;      <span class="comment">// module_invoke returns NULL for nonexisting hooks, so if no updates</span></div>
<div class="line"><a name="l00482"></a><span class="lineno">  482</span>&#160;      <span class="comment">// are removed, it will == 0.</span></div>
<div class="line"><a name="l00483"></a><span class="lineno">  483</span>&#160;      $last_removed = module_invoke($module, <span class="stringliteral">&#39;update_last_removed&#39;</span>);</div>
<div class="line"><a name="l00484"></a><span class="lineno">  484</span>&#160;      <span class="keywordflow">if</span> ($schema_version &lt; $last_removed) {</div>
<div class="line"><a name="l00485"></a><span class="lineno">  485</span>&#160;        <a class="code" href="group__errorhandling.html#ga23fe9e1e8c1e5ade39256106044b6da4">drush_set_error</a>(<span class="stringliteral">&#39;PROVISION_DRUPAL_UPDATE_FAILED&#39;</span>, <a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>( $module .<span class="stringliteral">&#39; module can not be updated. Its schema version is &#39;</span>. $schema_version .<span class="stringliteral">&#39;. Updates up to and including &#39;</span>. $last_removed .<span class="stringliteral">&#39; have been removed in this release. In order to update &#39;</span>. $module .<span class="stringliteral">&#39; module, you will first &lt;a href=&quot;http://drupal.org/upgrade&quot;&gt;need to upgrade&lt;/a&gt; to the last version in which these updates were available.&#39;</span>));</div>
<div class="line"><a name="l00486"></a><span class="lineno">  486</span>&#160;        <span class="keywordflow">continue</span>;</div>
<div class="line"><a name="l00487"></a><span class="lineno">  487</span>&#160;      }</div>
<div class="line"><a name="l00488"></a><span class="lineno">  488</span>&#160;</div>
<div class="line"><a name="l00489"></a><span class="lineno">  489</span>&#160;      $updates = drupal_map_assoc($updates);</div>
<div class="line"><a name="l00490"></a><span class="lineno">  490</span>&#160;</div>
<div class="line"><a name="l00491"></a><span class="lineno">  491</span>&#160;      <span class="comment">// Record the starting update number for each module.</span></div>
<div class="line"><a name="l00492"></a><span class="lineno">  492</span>&#160;      <span class="keywordflow">foreach</span> (array_keys($updates) as $update) {</div>
<div class="line"><a name="l00493"></a><span class="lineno">  493</span>&#160;        <span class="keywordflow">if</span> ($update &gt; $schema_version) {</div>
<div class="line"><a name="l00494"></a><span class="lineno">  494</span>&#160;          $start[$module] = $update;</div>
<div class="line"><a name="l00495"></a><span class="lineno">  495</span>&#160;          <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00496"></a><span class="lineno">  496</span>&#160;        }</div>
<div class="line"><a name="l00497"></a><span class="lineno">  497</span>&#160;      }</div>
<div class="line"><a name="l00498"></a><span class="lineno">  498</span>&#160;      <span class="keywordflow">if</span> (isset($start[<span class="stringliteral">&#39;system&#39;</span>])) {</div>
<div class="line"><a name="l00499"></a><span class="lineno">  499</span>&#160;        <span class="comment">// Ensure system module&#39;s updates run first.</span></div>
<div class="line"><a name="l00500"></a><span class="lineno">  500</span>&#160;        $start = array(<span class="stringliteral">&#39;system&#39;</span> =&gt; $start[<span class="stringliteral">&#39;system&#39;</span>]) + $start;</div>
<div class="line"><a name="l00501"></a><span class="lineno">  501</span>&#160;      }</div>
<div class="line"><a name="l00502"></a><span class="lineno">  502</span>&#160;</div>
<div class="line"><a name="l00503"></a><span class="lineno">  503</span>&#160;      <span class="comment">// Record any pending updates. Used for confirmation prompt.</span></div>
<div class="line"><a name="l00504"></a><span class="lineno">  504</span>&#160;      <span class="keywordflow">foreach</span> (array_keys($updates) as $update) {</div>
<div class="line"><a name="l00505"></a><span class="lineno">  505</span>&#160;        <span class="keywordflow">if</span> ($update &gt; $schema_version) {</div>
<div class="line"><a name="l00506"></a><span class="lineno">  506</span>&#160;          <span class="keywordflow">if</span> (class_exists(<span class="stringliteral">&#39;ReflectionFunction&#39;</span>)) {</div>
<div class="line"><a name="l00507"></a><span class="lineno">  507</span>&#160;            <span class="comment">// The description for an update comes from its Doxygen.</span></div>
<div class="line"><a name="l00508"></a><span class="lineno">  508</span>&#160;            $func = <span class="keyword">new</span> ReflectionFunction($module. <span class="stringliteral">&#39;_update_&#39;</span>. $update);</div>
<div class="line"><a name="l00509"></a><span class="lineno">  509</span>&#160;            $description = trim(str_replace(array(<span class="stringliteral">&quot;\n&quot;</span>, <span class="charliteral">&#39;*&#39;</span>, <span class="charliteral">&#39;/&#39;</span>), <span class="stringliteral">&#39;&#39;</span>, $func-&gt;getDocComment()));</div>
<div class="line"><a name="l00510"></a><span class="lineno">  510</span>&#160;          }</div>
<div class="line"><a name="l00511"></a><span class="lineno">  511</span>&#160;          <span class="keywordflow">if</span> (empty($description)) {</div>
<div class="line"><a name="l00512"></a><span class="lineno">  512</span>&#160;            $description = <a class="code" href="group__outputfunctions.html#ga1218abcb1e27dd3bb412113d1e344d96">dt</a>(<span class="stringliteral">&#39;description not available&#39;</span>);</div>
<div class="line"><a name="l00513"></a><span class="lineno">  513</span>&#160;          }</div>
<div class="line"><a name="l00514"></a><span class="lineno">  514</span>&#160;</div>
<div class="line"><a name="l00515"></a><span class="lineno">  515</span>&#160;          $return[] = array(<span class="stringliteral">&#39;module&#39;</span> =&gt; ucfirst($module), <span class="stringliteral">&#39;update_id&#39;</span> =&gt; $update, <span class="stringliteral">&#39;description&#39;</span> =&gt; $description);</div>
<div class="line"><a name="l00516"></a><span class="lineno">  516</span>&#160;        }</div>
<div class="line"><a name="l00517"></a><span class="lineno">  517</span>&#160;      }</div>
<div class="line"><a name="l00518"></a><span class="lineno">  518</span>&#160;    }</div>
<div class="line"><a name="l00519"></a><span class="lineno">  519</span>&#160;  }</div>
<div class="line"><a name="l00520"></a><span class="lineno">  520</span>&#160;</div>
<div class="line"><a name="l00521"></a><span class="lineno">  521</span>&#160;  <span class="keywordflow">return</span> array($return, $start);</div>
<div class="line"><a name="l00522"></a><span class="lineno">  522</span>&#160;}</div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Tue Mar 29 2016 07:27:28 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>