update.php

  1. <?php
  2. // $Id: update.php,v 1.252 2008/02/03 18:41:16 goba Exp $
  3. /**
  4.  * @file
  5.  * Administrative page for handling updates from one Drupal version to another.
  6.  *
  7.  * Point your browser to "http://www.example.com/update.php" and follow the
  8.  * instructions.
  9.  *
  10.  * If you are not logged in as administrator, you will need to modify the access
  11.  * check statement inside your settings.php file. After finishing the upgrade,
  12.  * be sure to open settings.php again, and change it back to its original state!
  13.  */
  14. /**
  15.  * Global flag to identify update.php run, and so avoid various unwanted
  16.  * operations, such as hook_init() and hook_exit() invokes, css/js preprocessing
  17.  * and translation, and solve some theming issues. This flag is checked on several
  18.  * places in Drupal code (not just update.php).
  19.  */
  20. define('MAINTENANCE_MODE''update');
  21. /**
  22.  * Add a column to a database using syntax appropriate for PostgreSQL.
  23.  * Save result of SQL commands in $ret array.
  24.  *
  25.  * Note: when you add a column with NOT NULL and you are not sure if there are
  26.  * already rows in the table, you MUST also add DEFAULT. Otherwise PostgreSQL
  27.  * won't work when the table is not empty, and db_add_column() will fail.
  28.  * To have an empty string as the default, you must use: 'default' => "''"
  29.  * in the $attributes array. If NOT NULL and DEFAULT are set the PostgreSQL
  30.  * version will set values of the added column in old rows to the
  31.  * DEFAULT value.
  32.  *
  33.  * @param $ret
  34.  *   Array to which results will be added.
  35.  * @param $table
  36.  *   Name of the table, without {}
  37.  * @param $column
  38.  *   Name of the column
  39.  * @param $type
  40.  *   Type of column
  41.  * @param $attributes
  42.  *   Additional optional attributes. Recognized attributes:
  43.  *     not null => TRUE|FALSE
  44.  *     default  => NULL|FALSE|value (the value must be enclosed in '' marks)
  45.  * @return
  46.  *   nothing, but modifies $ret parameter.
  47.  */
  48. function db_add_column(&$ret$table$column$type$attributes = array()) {
  49.   if (array_key_exists('not null'$attributes) and $attributes['not null']) {
  50.     $not_null 'NOT NULL';
  51.   }
  52.   if (array_key_exists('default'$attributes)) {
  53.     if (is_null($attributes['default'])) {
  54.       $default_val 'NULL';
  55.       $default 'default NULL';
  56.     }
  57.     elseif ($attributes['default'] === FALSE) {
  58.       $default '';
  59.     }
  60.     else {
  61.       $default_val "$attributes[default]";
  62.       $default "default $attributes[default]";
  63.     }
  64.   }
  65.   $ret[] = update_sql("ALTER TABLE {"$table ."} ADD $column $type");
  66.   if (!empty($default)) {
  67.     $ret[] = update_sql("ALTER TABLE {"$table ."} ALTER $column SET $default");
  68.   }
  69.   if (!empty($not_null)) {
  70.     if (!empty($default)) {
  71.       $ret[] = update_sql("UPDATE {"$table ."} SET $column = $default_val");
  72.     }
  73.     $ret[] = update_sql("ALTER TABLE {"$table ."} ALTER $column SET NOT NULL");
  74.   }
  75. }
  76. /**
  77.  * Change a column definition using syntax appropriate for PostgreSQL.
  78.  * Save result of SQL commands in $ret array.
  79.  *
  80.  * Remember that changing a column definition involves adding a new column
  81.  * and dropping an old one. This means that any indices, primary keys and
  82.  * sequences from serial-type columns are dropped and might need to be
  83.  * recreated.
  84.  *
  85.  * @param $ret
  86.  *   Array to which results will be added.
  87.  * @param $table
  88.  *   Name of the table, without {}
  89.  * @param $column
  90.  *   Name of the column to change
  91.  * @param $column_new
  92.  *   New name for the column (set to the same as $column if you don't want to change the name)
  93.  * @param $type
  94.  *   Type of column
  95.  * @param $attributes
  96.  *   Additional optional attributes. Recognized attributes:
  97.  *     not null => TRUE|FALSE
  98.  *     default  => NULL|FALSE|value (with or without '', it won't be added)
  99.  * @return
  100.  *   nothing, but modifies $ret parameter.
  101.  */
  102. function db_change_column(&$ret$table$column$column_new$type$attributes = array()) {
  103.   if (array_key_exists('not null'$attributes) and $attributes['not null']) {
  104.     $not_null 'NOT NULL';
  105.   }
  106.   if (array_key_exists('default'$attributes)) {
  107.     if (is_null($attributes['default'])) {
  108.       $default_val 'NULL';
  109.       $default 'default NULL';
  110.     }
  111.     elseif ($attributes['default'] === FALSE) {
  112.       $default '';
  113.     }
  114.     else {
  115.       $default_val "$attributes[default]";
  116.       $default "default $attributes[default]";
  117.     }
  118.   }
  119.   $ret[] = update_sql("ALTER TABLE {"$table ."} RENAME $column TO "$column ."_old");
  120.   $ret[] = update_sql("ALTER TABLE {"$table ."} ADD $column_new $type");
  121.   $ret[] = update_sql("UPDATE {"$table ."} SET $column_new = "$column ."_old");
  122.   if ($default) { $ret[] = update_sql("ALTER TABLE {"$table ."} ALTER $column_new SET $default"); }
  123.   if ($not_null) { $ret[] = update_sql("ALTER TABLE {"$table ."} ALTER $column_new SET NOT NULL"); }
  124.   $ret[] = update_sql("ALTER TABLE {"$table ."} DROP "$column ."_old");
  125. }
  126. /**
  127.  * Perform one update and store the results which will later be displayed on
  128.  * the finished page.
  129.  *
  130.  * An update function can force the current and all later updates for this
  131.  * module to abort by returning a $ret array with an element like:
  132.  * $ret['#abort'] = array('success' => FALSE, 'query' => 'What went wrong');
  133.  * The schema version will not be updated in this case, and all the
  134.  * aborted updates will continue to appear on update.php as updates that
  135.  * have not yet been run.
  136.  *
  137.  * @param $module
  138.  *   The module whose update will be run.
  139.  * @param $number
  140.  *   The update number to run.
  141.  * @param $context
  142.  *   The batch context array
  143.  */
  144. function update_do_one($module$number, &$context) {
  145.   // If updates for this module have been aborted
  146.   // in a previous step, go no further.
  147.   if (!empty($context['results'][$module]['#abort'])) {
  148.     return;
  149.   }
  150.   $function $module .'_update_'$number;
  151.   if (function_exists($function)) {
  152.     $ret $function($context['sandbox']);
  153.   }
  154.   if (isset($ret['#finished'])) {
  155.     $context['finished'] = $ret['#finished'];
  156.     unset($ret['#finished']);
  157.   }
  158.   if (!isset($context['results'][$module])) {
  159.     $context['results'][$module] = array();
  160.   }
  161.   if (!isset($context['results'][$module][$number])) {
  162.     $context['results'][$module][$number] = array();
  163.   }
  164.   $context['results'][$module][$number] = array_merge($context['results'][$module][$number], $ret);
  165.   if (!empty($ret['#abort'])) {
  166.     $context['results'][$module]['#abort'] = TRUE;
  167.   }
  168.   // Record the schema update if it was completed successfully.
  169.   if ($context['finished'] == && empty($context['results'][$module]['#abort'])) {
  170.     drupal_set_installed_schema_version($module$number);
  171.   }
  172.   $context['message'] = 'Updating 'check_plain($module) .' module';
  173. }
  174. function update_selection_page() {
  175.   $output '<p>The version of Drupal you are updating from has been automatically detected. You can select a different version, but you should not need to.</p>';
  176.   $output .= '<p>Click Update to start the update process.</p>';
  177.   drupal_set_title('Drupal database update');
  178.   $output .= drupal_get_form('update_script_selection_form');
  179.   update_task_list('select');
  180.   return $output;
  181. }
  182. function update_script_selection_form() {
  183.   $form = array();
  184.   $form['start'] = array(
  185.     '#tree' => TRUE,
  186.     '#type' => 'fieldset',
  187.     '#title' => 'Select versions',
  188.     '#collapsible' => TRUE,
  189.     '#collapsed' => TRUE,
  190.   );
  191.   // Ensure system.module's updates appear first
  192.   $form['start']['system'] = array();
  193.   $modules drupal_get_installed_schema_version(NULLFALSETRUE);
  194.   foreach ($modules as $module => $schema_version) {
  195.     $updates drupal_get_schema_versions($module);
  196.     // Skip incompatible module updates completely, otherwise test schema versions.
  197.     if (!update_check_incompatibility($module) && $updates !== FALSE && $schema_version >= 0) {
  198.       // module_invoke returns NULL for nonexisting hooks, so if no updates
  199.       // are removed, it will == 0.
  200.       $last_removed module_invoke($module'update_last_removed');
  201.       if ($schema_version $last_removed) {
  202.         $form['start'][$module] = array(
  203.           '#value'  => '<em>'$module .'</em> 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 <em>'$module .'</em> module, you will first <a href="http://drupal.org/upgrade">need to upgrade</a> to the last version in which these updates were available.',
  204.           '#prefix' => '<div class="warning">',
  205.           '#suffix' => '</div>',
  206.         );
  207.         $form['start']['#collapsed'] = FALSE;
  208.         continue;
  209.       }
  210.       $updates drupal_map_assoc($updates);
  211.       $updates[] = 'No updates available';
  212.       $default $schema_version;
  213.       foreach (array_keys($updates) as $update) {
  214.         if ($update $schema_version) {
  215.           $default $update;
  216.           break;
  217.         }
  218.       }
  219.       $form['start'][$module] = array(
  220.         '#type' => 'select',
  221.         '#title' => $module .' module',
  222.         '#default_value' => $default,
  223.         '#options' => $updates,
  224.       );
  225.     }
  226.   }
  227.   $form['has_js'] = array(
  228.     '#type' => 'hidden',
  229.     '#default_value' => FALSE,
  230.     '#attributes' => array('id' => 'edit-has_js'),
  231.   );
  232.   $form['submit'] = array(
  233.     '#type' => 'submit',
  234.     '#value' => 'Update',
  235.   );
  236.   return $form;
  237. }
  238. function update_batch() {
  239.   global $base_url;
  240.   $operations = array();
  241.   // Set the installed version so updates start at the correct place.
  242.   foreach ($_POST['start'] as $module => $version) {
  243.     drupal_set_installed_schema_version($module$version 1);
  244.     $updates drupal_get_schema_versions($module);
  245.     $max_version max($updates);
  246.     if ($version <= $max_version) {
  247.       foreach ($updates as $update) {
  248.         if ($update >= $version) {
  249.           $operations[] = array('update_do_one', array($module$update));
  250.         }
  251.       }
  252.     }
  253.   }
  254.   $batch = array(
  255.     'operations' => $operations,
  256.     'title' => 'Updating',
  257.     'init_message' => 'Starting updates',
  258.     '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.',
  259.     'finished' => 'update_finished',
  260.   );
  261.   batch_set($batch);
  262.   batch_process($base_url .'/update.php?op=results'$base_url .'/update.php');
  263. }
  264. function update_finished($success$results$operations) {
  265.   // clear the caches in case the data has been updated.
  266.   drupal_flush_all_caches();
  267.   $_SESSION['update_results'] = $results;
  268.   $_SESSION['update_success'] = $success;
  269.   $_SESSION['updates_remaining'] = $operations;
  270. }
  271. function update_results_page() {
  272.   drupal_set_title('Drupal database update');
  273.   // NOTE: we can't use l() here because the URL would point to 'update.php?q=admin'.
  274.   $links[] = '<a href="'base_path() .'">Main page</a>';
  275.   $links[] = '<a href="'base_path() .'?q=admin">Administration pages</a>';
  276.   update_task_list();
  277.   // Report end result
  278.   if (module_exists('dblog')) {
  279.     $log_message ' All errors have been <a href="'base_path() .'?q=admin/reports/dblog">logged</a>.';
  280.   }
  281.   else {
  282.     $log_message ' All errors have been logged.';
  283.   }
  284.   if ($_SESSION['update_success']) {
  285.     $output '<p>Updates were attempted. If you see no failures below, you may proceed happily to the <a href="'base_path() .'?q=admin">administration pages</a>. Otherwise, you may need to update your database manually.'$log_message .'</p>';
  286.   }
  287.   else {
  288.     list($module$version) = array_pop(reset($_SESSION['updates_remaining']));
  289.     $output '<p class="error">The update process was aborted prematurely while running <strong>update #'$version .' in '$module .'.module</strong>.'$log_message;
  290.     if (module_exists('dblog')) {
  291.       $output .= ' You may need to check the <code>watchdog</code> database table manually.';
  292.     }
  293.     $output .= '</p>';
  294.   }
  295.   if (!empty($GLOBALS['update_free_access'])) {
  296.     $output .= "<p><strong>Reminder: don't forget to set the <code>\$update_free_access</code> value in your <code>settings.php</code> file back to <code>FALSE</code>.</strong></p>";
  297.   }
  298.   $output .= theme('item_list'$links);
  299.   // Output a list of queries executed
  300.   if (!empty($_SESSION['update_results'])) {
  301.     $output .= '<div id="update-results">';
  302.     $output .= '<h2>The following queries were executed</h2>';
  303.     foreach ($_SESSION['update_results'] as $module => $updates) {
  304.       $output .= '<h3>'$module .' module</h3>';
  305.       foreach ($updates as $number => $queries) {
  306.         if ($number != '#abort') {
  307.           $output .= '<h4>Update #'$number .'</h4>';
  308.           $output .= '<ul>';
  309.           foreach ($queries as $query) {
  310.             if ($query['success']) {
  311.               $output .= '<li class="success">'$query['query'] .'</li>';
  312.             }
  313.             else {
  314.               $output .= '<li class="failure"><strong>Failed:</strong> '$query['query'] .'</li>';
  315.             }
  316.           }
  317.           if (!count($queries)) {
  318.             $output .= '<li class="none">No queries</li>';
  319.           }
  320.         }
  321.         $output .= '</ul>';
  322.       }
  323.     }
  324.     $output .= '</div>';
  325.   }
  326.   unset($_SESSION['update_results']);
  327.   unset($_SESSION['update_success']);
  328.   return $output;
  329. }
  330. function update_info_page() {
  331.   // Change query-strings on css/js files to enforce reload for all users.
  332.   _drupal_flush_css_js();
  333.   // Flush the cache of all data for the update status module.
  334.   if (db_table_exists('cache_update')) {
  335.     cache_clear_all('*''cache_update'TRUE);
  336.   }
  337.   update_task_list('info');
  338.   drupal_set_title('Drupal database update');
  339.   $output '<p>Use this utility to update your database whenever a new release of Drupal or a module is installed.</p><p>For more detailed information, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.</p>';
  340.   $output .= "<ol>\n";
  341.   $output .= "<li><strong>Back up your database</strong>. This process will change your database values and in case of emergency you may need to revert to a backup.</li>\n";
  342.   $output .= "<li><strong>Back up your code</strong>. Hint: when backing up module code, do not leave that backup in the 'modules' or 'sites/*/modules' directories as this may confuse Drupal's auto-discovery mechanism.</li>\n";
  343.   $output .= '<li>Put your site into <a href="'base_path() .'?q=admin/settings/site-maintenance">maintenance mode</a>.</li>'."\n";
  344.   $output .= "<li>Install your new files in the appropriate location, as described in the handbook.</li>\n";
  345.   $output .= "</ol>\n";
  346.   $output .= "<p>When you have performed the steps above, you may proceed.</p>\n";
  347.   $output .= '<form method="post" action="update.php?op=selection"><input type="submit" value="Continue" /></form>';
  348.   $output .= "\n";
  349.   return $output;
  350. }
  351. function update_access_denied_page() {
  352.   drupal_set_title('Access denied');
  353.   return '<p>Access denied. You are not authorized to access this page. Please log in as the admin user (the first user you created). If you cannot log in, you will have to edit <code>settings.php</code> to bypass this access check. To do this:</p>
  354. <ol>
  355.  <li>With a text editor find the settings.php file on your system. From the main Drupal directory that you installed all the files into, go to <code>sites/your_site_name</code> if such directory exists, or else to <code>sites/default</code> which applies otherwise.</li>
  356.  <li>There is a line inside your settings.php file that says <code>$update_free_access = FALSE;</code>. Change it to <code>$update_free_access = TRUE;</code>.</li>
  357.  <li>As soon as the update.php script is done, you must change the settings.php file back to its original form with <code>$update_free_access = FALSE;</code>.</li>
  358.  <li>To avoid having this problem in future, remember to log in to your website as the admin user (the user you first created) before you backup your database at the beginning of the update process.</li>
  359. </ol>';
  360. }
  361. /**
  362.  * Create the batch table.
  363.  *
  364.  * This is part of the Drupal 5.x to 6.x migration.
  365.  */
  366. function update_create_batch_table() {
  367.   // If batch table exists, update is not necessary
  368.   if (db_table_exists('batch')) {
  369.     return;
  370.   }
  371.   $schema['batch'] = array(
  372.     'fields' => array(
  373.       'bid'       => array('type' => 'serial''unsigned' => TRUE'not null' => TRUE),
  374.       'token'     => array('type' => 'varchar''length' => 64'not null' => TRUE),
  375.       'timestamp' => array('type' => 'int''not null' => TRUE),
  376.       'batch'     => array('type' => 'text''not null' => FALSE'size' => 'big')
  377.     ),
  378.     'primary key' => array('bid'),
  379.     'indexes' => array('token' => array('token')),
  380.   );
  381.   $ret = array();
  382.   db_create_table($ret'batch'$schema['batch']);
  383.   return $ret;
  384. }
  385. /**
  386.  * Disable anything in the {system} table that is not compatible with the
  387.  * current version of Drupal core.
  388.  */
  389. function update_fix_compatibility() {
  390.   $ret = array();
  391.   $incompatible = array();
  392.   $query db_query("SELECT name, type, status FROM {system} WHERE status = 1 AND type IN ('module','theme')");
  393.   while ($result db_fetch_object($query)) {
  394.     if (update_check_incompatibility($result->name$result->type)) {
  395.       $incompatible[] = $result->name;
  396.     }
  397.   }
  398.   if (!empty($incompatible)) {
  399.     $ret[] = update_sql("UPDATE {system} SET status = 0 WHERE name IN ('"implode("','"$incompatible) ."')");
  400.   }
  401.   return $ret;
  402. }
  403. /**
  404.  * Helper function to test compatibility of a module or theme.
  405.  */
  406. function update_check_incompatibility($name$type 'module') {
  407.   static $themes$modules;
  408.   // Store values of expensive functions for future use.
  409.   if (empty($themes) || empty($modules)) {
  410.     $themes system_theme_data();
  411.     $modules module_rebuild_cache();
  412.   }
  413.   if ($type == 'module' && isset($modules[$name])) {
  414.     $file $modules[$name];
  415.   }
  416.   else if ($type == 'theme' && isset($themes[$name])) {
  417.     $file $themes[$name];
  418.   }
  419.   if (!isset($file)
  420.       || !isset($file->info['core'])
  421.       || $file->info['core'] != DRUPAL_CORE_COMPATIBILITY
  422.       || version_compare(phpversion(), $file->info['php']) < 0) {
  423.     return TRUE;
  424.   }
  425.   return FALSE;
  426. }
  427. /**
  428.  * Perform Drupal 5.x to 6.x updates that are required for update.php
  429.  * to function properly.
  430.  *
  431.  * This function runs when update.php is run the first time for 6.x,
  432.  * even before updates are selected or performed.  It is important
  433.  * that if updates are not ultimately performed that no changes are
  434.  * made which make it impossible to continue using the prior version.
  435.  * Just adding columns is safe.  However, renaming the
  436.  * system.description column to owner is not.  Therefore, we add the
  437.  * system.owner column and leave it to system_update_6008() to copy
  438.  * the data from description and remove description. The same for
  439.  * renaming locales_target.locale to locales_target.language, which
  440.  * will be finished by locale_update_6002().
  441.  */
  442. function update_fix_d6_requirements() {
  443.   $ret = array();
  444.   if (drupal_get_installed_schema_version('system') < 6000 && !variable_get('update_d6_requirements'FALSE)) {
  445.     $spec = array('type' => 'int''size' => 'small''default' => 0'not null' => TRUE);
  446.     db_add_field($ret'cache''serialized'$spec);
  447.     db_add_field($ret'cache_filter''serialized'$spec);
  448.     db_add_field($ret'cache_page''serialized'$spec);
  449.     db_add_field($ret'cache_menu''serialized'$spec);
  450.     db_add_field($ret'system''info', array('type' => 'text'));
  451.     db_add_field($ret'system''owner', array('type' => 'varchar''length' => 255'not null' => TRUE'default' => ''));
  452.     if (db_table_exists('locales_target')) {
  453.       db_add_field($ret'locales_target''language', array('type' => 'varchar''length' => 12'not null' => TRUE'default' => ''));
  454.     }
  455.     if (db_table_exists('locales_source')) {
  456.       db_add_field($ret'locales_source''textgroup', array('type' => 'varchar''length' => 255'not null' => TRUE'default' => 'default'));
  457.       db_add_field($ret'locales_source''version', array('type' => 'varchar''length' => 20'not null' => TRUE'default' => 'none'));
  458.     }
  459.     variable_set('update_d6_requirements'TRUE);
  460.     // Create the cache_block table. See system_update_6027() for more details.
  461.     $schema['cache_block'] = array(
  462.       'fields' => array(
  463.         'cid'        => array('type' => 'varchar''length' => 255'not null' => TRUE'default' => ''),
  464.         'data'       => array('type' => 'blob''not null' => FALSE'size' => 'big'),
  465.         'expire'     => array('type' => 'int''not null' => TRUE'default' => 0),
  466.         'created'    => array('type' => 'int''not null' => TRUE'default' => 0),
  467.         'headers'    => array('type' => 'text''not null' => FALSE),
  468.         'serialized' => array('type' => 'int''size' => 'small''not null' => TRUE'default' => 0)
  469.       ),
  470.       'indexes' => array('expire' => array('expire')),
  471.       'primary key' => array('cid'),
  472.     );
  473.     db_create_table($ret'cache_block'$schema['cache_block']);
  474.   }
  475.   return $ret;
  476. }
  477. /**
  478.  * Add the update task list to the current page.
  479.  */
  480. function update_task_list($active NULL) {
  481.   // Default list of tasks.
  482.   $tasks = array(
  483.     'info' => 'Overview',
  484.     'select' => 'Select updates',
  485.     'run' => 'Run updates',
  486.     'finished' => 'Review log',
  487.   );
  488.   drupal_set_content('left'theme('task_list'$tasks$active));
  489. }
  490. /**
  491.  * Check update requirements and report any errors.
  492.  */
  493. function update_check_requirements() {
  494.   // Check the system module requirements only.
  495.   $requirements module_invoke('system''requirements''update');
  496.   $severity drupal_requirements_severity($requirements);
  497.   // If there are issues, report them.
  498.   if ($severity != REQUIREMENT_OK) {
  499.     foreach ($requirements as $requirement) {
  500.       if (isset($requirement['severity']) && $requirement['severity'] != REQUIREMENT_OK) {
  501.         $message = isset($requirement['description']) ? $requirement['description'] : '';
  502.         if (isset($requirement['value']) && $requirement['value']) {
  503.           $message .= ' (Currently using '$requirement['title'] .' '$requirement['value'] .')';
  504.         }
  505.         drupal_set_message($message'warning');
  506.       }
  507.     }
  508.   }
  509. }
  510. // Some unavoidable errors happen because the database is not yet up-to-date.
  511. // Our custom error handler is not yet installed, so we just suppress them.
  512. ini_set('display_errors'FALSE);
  513. require_once './includes/bootstrap.inc';
  514. // We only load DRUPAL_BOOTSTRAP_CONFIGURATION for the update requirements
  515. // check to avoid reaching the PHP memory limit.
  516. $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
  517. if (empty($op)) {
  518.   // Minimum load of components.
  519.   drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);
  520.   require_once './includes/install.inc';
  521.   require_once './includes/file.inc';
  522.   require_once './modules/system/system.install';
  523.   // Load module basics.
  524.   include_once './includes/module.inc';
  525.   $module_list['system']['filename'] = 'modules/system/system.module';
  526.   $module_list['filter']['filename'] = 'modules/filter/filter.module';
  527.   module_list(TRUEFALSEFALSE$module_list);
  528.   drupal_load('module''system');
  529.   drupal_load('module''filter');
  530.   // Set up $language, since the installer components require it.
  531.   drupal_init_language();
  532.   // Set up theme system for the maintenance page.
  533.   drupal_maintenance_theme();
  534.   // Check the update requirements for Drupal.
  535.   update_check_requirements();
  536.   // Display the warning messages (if any) in a dedicated maintenance page,
  537.   // or redirect to the update information page if no message.
  538.   $messages drupal_set_message();
  539.   if (!empty($messages['warning'])) {
  540.     drupal_maintenance_theme();
  541.     print theme('update_page''<form method="post" action="update.php?op=info"><input type="submit" value="Continue" /></form>'FALSE);
  542.     exit;
  543.   }
  544.   install_goto('update.php?op=info');
  545. }
  546. drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
  547. drupal_maintenance_theme();
  548. // This must happen *after* drupal_bootstrap(), since it calls
  549. // variable_(get|set), which only works after a full bootstrap.
  550. update_create_batch_table();
  551. // Turn error reporting back on. From now on, only fatal errors (which are
  552. // not passed through the error handler) will cause a message to be printed.
  553. ini_set('display_errors'TRUE);
  554. // Access check:
  555. if (!empty($update_free_access) || $user->uid == 1) {
  556.   include_once './includes/install.inc';
  557.   include_once './includes/batch.inc';
  558.   drupal_load_updates();
  559.   update_fix_d6_requirements();
  560.   update_fix_compatibility();
  561.   $op = isset($_REQUEST['op']) ? $_REQUEST['op'] : '';
  562.   switch ($op) {
  563.     // update.php ops
  564.     case 'info':
  565.       $output update_info_page();
  566.       break;
  567.     case 'selection':
  568.       $output update_selection_page();
  569.       break;
  570.     case 'Update':
  571.       update_batch();
  572.       break;
  573.     case 'results':
  574.       $output update_results_page();
  575.       break;
  576.     // Regular batch ops : defer to batch processing API
  577.     default:
  578.       update_task_list('run');
  579.       $output _batch_page();
  580.       break;
  581.   }
  582. }
  583. else {
  584.   $output update_access_denied_page();
  585. }
  586. if (isset($output) && $output) {
  587.   // We defer the display of messages until all updates are done.
  588.   $progress_page = ($batch batch_get()) && isset($batch['running']);
  589.   print theme('update_page'$output, !$progress_page);
  590. }