2001-11-15 22:53:06 +00:00
< ? php
2004-08-21 06:42:38 +00:00
/**
* @ file
* Administrative page for handling updates from one Drupal version to another .
*
2011-10-31 04:05:57 +00:00
* Point your browser to " http://www.example.com/core/update.php " and follow the
2004-08-21 06:42:38 +00:00
* instructions .
*
2009-10-09 07:48:07 +00:00
* If you are not logged in using either the site maintenance account or an
* account with the " Administer software updates " permission , you will need to
* modify the access check statement inside your settings . php file . After
* finishing the upgrade , be sure to open settings . php again , and change it
* back to its original state !
2004-08-21 06:42:38 +00:00
*/
2001-12-16 14:42:51 +00:00
2013-06-06 08:08:39 +00:00
use Drupal\Core\DrupalKernel ;
2014-04-17 20:12:22 +00:00
use Drupal\Core\Page\DefaultHtmlPageRenderer ;
2014-04-25 19:13:44 +00:00
use Drupal\Core\Site\Settings ;
2013-11-23 02:58:43 +00:00
use Drupal\Core\Update\Form\UpdateScriptSelectionForm ;
2012-04-26 04:37:14 +00:00
use Symfony\Component\HttpFoundation\Request ;
use Symfony\Component\HttpFoundation\Response ;
2012-09-21 21:01:35 +00:00
use Symfony\Component\DependencyInjection\Reference ;
2012-04-26 04:37:14 +00:00
2011-10-31 04:05:57 +00:00
// Change the directory to the Drupal root.
chdir ( '..' );
2014-06-05 17:53:24 +00:00
require_once __DIR__ . '/vendor/autoload.php' ;
2013-09-02 19:53:23 +00:00
2012-09-14 15:19:14 +00:00
// Exit early if an incompatible PHP version would cause fatal errors.
2012-02-16 04:11:36 +00:00
// The minimum version is specified explicitly, as DRUPAL_MINIMUM_PHP is not
// yet available. It is defined in bootstrap.inc, but it is not possible to
// load that file yet as it would cause a fatal error on older versions of PHP.
2014-02-27 19:14:53 +00:00
if ( version_compare ( PHP_VERSION , '5.4.2' ) < 0 ) {
print 'Your PHP installation is too old. Drupal requires at least PHP 5.4.2. See the <a href="http://drupal.org/requirements">system requirements</a> page for more information.' ;
2012-02-16 04:11:36 +00:00
exit ;
}
2008-01-07 19:43:29 +00:00
/**
2010-03-26 22:14:46 +00:00
* Global flag indicating that update . php is being run .
*
2013-06-05 07:47:39 +00:00
* When this flag is set , various operations do not take place , such as css / js
* preprocessing and translation .
2012-02-16 04:11:36 +00:00
*
* This constant is defined using define () instead of const so that PHP
* versions older than 5.3 can display the proper PHP requirements instead of
* causing a fatal error .
2008-01-07 19:43:29 +00:00
*/
2012-02-16 04:11:36 +00:00
define ( 'MAINTENANCE_MODE' , 'update' );
2007-11-30 12:19:10 +00:00
2012-09-14 15:19:14 +00:00
/**
2012-12-02 15:30:41 +00:00
* Renders a form with a list of available database updates .
2012-09-14 15:19:14 +00:00
*/
2005-12-06 09:25:22 +00:00
function update_selection_page () {
2013-03-22 17:10:08 +00:00
// Make sure there is no stale theme registry.
2014-02-21 15:21:08 +00:00
\Drupal :: cache () -> deleteAll ();
2013-03-22 17:10:08 +00:00
2014-03-07 14:03:33 +00:00
$build = \Drupal :: formBuilder () -> getForm ( 'Drupal\Core\Update\Form\UpdateScriptSelectionForm' );
$build [ '#title' ] = 'Drupal database update' ;
2006-08-18 18:58:47 +00:00
2014-03-07 14:03:33 +00:00
return $build ;
2006-08-18 18:58:47 +00:00
}
2012-09-14 15:19:14 +00:00
/**
* Provides links to the homepage and administration pages .
*/
2008-08-31 12:45:41 +00:00
function update_helpful_links () {
2012-08-31 01:10:40 +00:00
$links [ 'front' ] = array (
'title' => t ( 'Front page' ),
'href' => '<front>' ,
);
2012-02-02 18:09:46 +00:00
if ( user_access ( 'access administration pages' )) {
2012-08-31 01:10:40 +00:00
$links [ 'admin-pages' ] = array (
'title' => t ( 'Administration pages' ),
'href' => 'admin' ,
);
2012-02-02 18:09:46 +00:00
}
2008-08-31 12:45:41 +00:00
return $links ;
}
2013-06-06 08:08:39 +00:00
/**
* Remove update overrides and flush all caches .
*
* This will need to be run once all ( if any ) updates are run . Do not call this
* while updates are running .
*/
function update_flush_all_caches () {
2014-01-21 10:58:16 +00:00
$GLOBALS [ 'conf' ][ 'update_service_provider_overrides' ] = FALSE ;
2013-09-16 03:58:06 +00:00
\Drupal :: service ( 'kernel' ) -> updateModules ( \Drupal :: moduleHandler () -> getModuleList ());
2013-06-06 08:08:39 +00:00
// No updates to run, so caches won't get flushed later. Clear them now.
drupal_flush_all_caches ();
}
2012-09-14 15:19:14 +00:00
/**
* Displays results of the update script with any accompanying errors .
*/
2008-08-31 12:45:41 +00:00
function update_results_page () {
2010-03-26 22:14:46 +00:00
// Report end result.
2013-10-16 12:17:55 +00:00
if ( \Drupal :: moduleHandler () -> moduleExists ( 'dblog' ) && user_access ( 'access site reports' )) {
2008-04-14 17:48:46 +00:00
$log_message = ' All errors have been <a href="' . base_path () . '?q=admin/reports/dblog">logged</a>.' ;
2007-10-02 08:41:13 +00:00
}
else {
$log_message = ' All errors have been logged.' ;
}
2007-05-04 09:41:37 +00:00
if ( $_SESSION [ 'update_success' ]) {
2012-02-02 18:09:46 +00:00
$output = '<p>Updates were attempted. If you see no failures below, you may proceed happily back to your <a href="' . base_path () . '">site</a>. Otherwise, you may need to update your database manually.' . $log_message . '</p>' ;
2006-03-01 22:19:24 +00:00
}
else {
2012-11-26 10:38:45 +00:00
$last = reset ( $_SESSION [ 'updates_remaining' ]);
list ( $module , $version ) = array_pop ( $last );
2008-04-14 17:48:46 +00:00
$output = '<p class="error">The update process was aborted prematurely while running <strong>update #' . $version . ' in ' . $module . '.module</strong>.' . $log_message ;
2013-10-16 12:17:55 +00:00
if ( \Drupal :: moduleHandler () -> moduleExists ( 'dblog' )) {
2007-10-02 08:41:13 +00:00
$output .= ' You may need to check the <code>watchdog</code> database table manually.' ;
}
$output .= '</p>' ;
2006-03-01 22:19:24 +00:00
}
2014-03-24 08:51:28 +00:00
if ( Settings :: get ( 'update_free_access' )) {
2013-01-07 11:45:26 +00:00
$output .= " <p><strong>Reminder: don't forget to set the <code> \$ settings['update_free_access']</code> value in your <code>settings.php</code> file back to <code>FALSE</code>.</strong></p> " ;
2001-11-15 22:53:06 +00:00
}
2007-05-06 05:47:52 +00:00
2013-07-20 19:35:36 +00:00
$links = array (
'#theme' => 'links' ,
'#links' => update_helpful_links (),
);
$output .= drupal_render ( $links );
2005-12-06 09:25:22 +00:00
2010-03-26 22:14:46 +00:00
// Output a list of queries executed.
2007-03-28 07:02:47 +00:00
if ( ! empty ( $_SESSION [ 'update_results' ])) {
2011-01-04 05:57:26 +00:00
$all_messages = '' ;
2005-12-06 09:25:22 +00:00
foreach ( $_SESSION [ 'update_results' ] as $module => $updates ) {
2010-02-03 18:16:23 +00:00
if ( $module != '#abort' ) {
2011-01-04 05:57:26 +00:00
$module_has_message = FALSE ;
$query_messages = '' ;
2010-02-03 18:16:23 +00:00
foreach ( $updates as $number => $queries ) {
2009-09-07 15:43:55 +00:00
$messages = array ();
2008-01-17 20:05:23 +00:00
foreach ( $queries as $query ) {
2009-09-07 15:43:55 +00:00
// If there is no message for this update, don't show anything.
if ( empty ( $query [ 'query' ])) {
continue ;
}
2011-01-04 05:57:26 +00:00
2008-01-17 20:05:23 +00:00
if ( $query [ 'success' ]) {
2009-09-07 15:43:55 +00:00
$messages [] = '<li class="success">' . $query [ 'query' ] . '</li>' ;
2008-01-17 20:05:23 +00:00
}
else {
2009-09-07 15:43:55 +00:00
$messages [] = '<li class="failure"><strong>Failed:</strong> ' . $query [ 'query' ] . '</li>' ;
2008-01-17 20:05:23 +00:00
}
2005-12-06 09:25:22 +00:00
}
2009-09-07 15:43:55 +00:00
if ( $messages ) {
2011-01-04 05:57:26 +00:00
$module_has_message = TRUE ;
$query_messages .= '<h4>Update #' . $number . " </h4> \n " ;
$query_messages .= '<ul>' . implode ( " \n " , $messages ) . " </ul> \n " ;
2005-12-06 09:25:22 +00:00
}
}
2011-01-04 05:57:26 +00:00
// If there were any messages in the queries then prefix them with the
// module name and add it to the global message list.
if ( $module_has_message ) {
$all_messages .= '<h3>' . $module . " module</h3> \n " . $query_messages ;
}
2005-12-06 09:25:22 +00:00
}
}
2011-01-04 05:57:26 +00:00
if ( $all_messages ) {
2013-03-27 05:03:16 +00:00
$output .= '<div class="update-results"><h2>The following updates returned messages</h2>' ;
2011-01-04 05:57:26 +00:00
$output .= $all_messages ;
$output .= '</div>' ;
}
2005-12-06 09:25:22 +00:00
}
2007-05-04 09:41:37 +00:00
unset ( $_SESSION [ 'update_results' ]);
unset ( $_SESSION [ 'update_success' ]);
2005-12-06 09:25:22 +00:00
2014-03-07 14:03:33 +00:00
$build = array (
'#title' => 'Drupal database update' ,
'#markup' => $output ,
);
return $build ;
2001-11-15 22:53:06 +00:00
}
2012-11-27 15:40:05 +00:00
/**
* Provides an overview of the Drupal database update .
*
* This page provides cautionary suggestions that should happen before
* proceeding with the update to ensure data integrity .
*
* @ return
* Rendered HTML form .
*/
2005-08-17 01:44:14 +00:00
function update_info_page () {
2008-01-07 19:43:29 +00:00
// Change query-strings on css/js files to enforce reload for all users.
_drupal_flush_css_js ();
2008-01-30 22:13:25 +00:00
// Flush the cache of all data for the update status module.
2013-12-22 21:03:21 +00:00
$keyvalue = \Drupal :: service ( 'keyvalue.expirable' );
$keyvalue -> get ( 'update' ) -> deleteAll ();
$keyvalue -> get ( 'update_available_release' ) -> deleteAll ();
2008-01-07 19:43:29 +00:00
2009-01-21 14:47:12 +00:00
$token = drupal_get_token ( 'update' );
2010-04-30 05:20:36 +00:00
$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/upgrade">upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.</p>' ;
2007-07-15 05:57:40 +00:00
$output .= " <ol> \n " ;
$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 " ;
2009-08-11 17:26:33 +00:00
$output .= '<li>Put your site into <a href="' . base_path () . '?q=admin/config/development/maintenance">maintenance mode</a>.</li>' . " \n " ;
2013-03-08 16:18:57 +00:00
$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 " ;
2007-07-15 05:57:40 +00:00
$output .= " <li>Install your new files in the appropriate location, as described in the handbook.</li> \n " ;
$output .= " </ol> \n " ;
$output .= " <p>When you have performed the steps above, you may proceed.</p> \n " ;
2011-10-01 16:11:43 +00:00
$form_action = check_url ( drupal_current_script_url ( array ( 'op' => 'selection' , 'token' => $token )));
2014-03-26 12:26:11 +00:00
$output .= '<form method="post" action="' . $form_action . '"><div class="form-actions form-wrapper" id="edit-actions"><input type="submit" value="Continue" class="button button--primary form-submit" /></div></form>' ;
2007-07-15 05:57:40 +00:00
$output .= " \n " ;
2014-03-07 14:03:33 +00:00
$build = array (
'#title' => 'Drupal database update' ,
'#markup' => $output ,
);
return $build ;
2005-08-17 01:44:14 +00:00
}
2012-11-27 15:40:05 +00:00
/**
* Renders a 403 access denied page for update . php .
*
* @ return
* Rendered HTML warning with 403 status .
*/
2005-08-17 01:44:14 +00:00
function update_access_denied_page () {
2010-03-06 06:31:24 +00:00
drupal_add_http_header ( 'Status' , '403 Forbidden' );
2013-12-05 18:02:36 +00:00
header ( \Drupal :: request () -> server -> get ( 'SERVER_PROTOCOL' ) . ' 403 Forbidden' );
Issue #1289536 by ParisLiakos, RobLoach, Crell, larowlan, fgm, pounard, Pancho, dawehner, scor, tim.plunkett, alexpott, socketwench: Switch Watchdog to a PSR-3 logging framework.
2014-05-22 09:38:46 +00:00
watchdog ( 'access denied' , 'update.php' , array (), WATCHDOG_WARNING );
2014-03-07 14:03:33 +00:00
$output = ' < p > Access denied . You are not authorized to access this page . Log in using either an account with the < em > administer software updates </ em > permission or the site maintenance account ( the account you created during installation ) . If you cannot log in , you will have to edit < code > settings . php </ code > to bypass this access check . To do this :</ p >
2005-08-17 01:44:14 +00:00
< ol >
2007-08-28 11:42:56 +00:00
< 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 >
2013-01-07 11:45:26 +00:00
< li > There is a line inside your settings . php file that says < code > $settings [ \ ' update_free_access\ ' ] = FALSE ; </ code >. Change it to < code > $settings [ \ ' update_free_access\ ' ] = TRUE ; </ code >.</ li >
< li > As soon as the update . php script is done , you must change the settings . php file back to its original form with < code > $settings [ \ ' update_free_access\ ' ] = FALSE ; </ code >.</ li >
2009-10-09 07:48:07 +00:00
< li > To avoid having this problem in the future , remember to log in to your website using either an account with the < em > administer software updates </ em > permission or the site maintenance account ( the account you created during installation ) before you backup your database at the beginning of the update process .</ li >
2005-08-17 01:44:14 +00:00
</ ol > ' ;
2014-03-07 14:03:33 +00:00
$build = array (
'#title' => 'Access denied' ,
'#markup' => $output ,
);
return $build ;
2001-11-15 22:53:06 +00:00
}
2002-05-11 17:23:45 +00:00
2009-10-09 07:48:07 +00:00
/**
* Determines if the current user is allowed to run update . php .
*
* @ return
* TRUE if the current user should be granted access , or FALSE otherwise .
*/
function update_access_allowed () {
2013-10-16 12:39:58 +00:00
$user = \Drupal :: currentUser ();
2009-10-09 07:48:07 +00:00
// Allow the global variable in settings.php to override the access check.
2014-03-24 08:51:28 +00:00
if ( Settings :: get ( 'update_free_access' )) {
2009-10-09 07:48:07 +00:00
return TRUE ;
}
// Calls to user_access() might fail during the Drupal 6 to 7 update process,
// so we fall back on requiring that the user be logged in as user #1.
try {
2013-09-16 03:58:06 +00:00
$module_handler = \Drupal :: moduleHandler ();
Issue #340723 by ParisLiakos, sun, Berdir, glennpratt, Cottser, swentel, alexpott, tstoeckler, Xano, tim.plunkett, BassistJimmyJam | beejeebus: Make modules and installation profiles only require .info.yml files.
2014-03-17 14:43:29 +00:00
$module_handler -> addModule ( 'user' , 'core/modules/user' );
2014-03-17 13:02:04 +00:00
$module_handler -> reload ();
Issue #340723 by ParisLiakos, sun, Berdir, glennpratt, Cottser, swentel, alexpott, tstoeckler, Xano, tim.plunkett, BassistJimmyJam | beejeebus: Make modules and installation profiles only require .info.yml files.
2014-03-17 14:43:29 +00:00
$module_filenames = $module_handler -> getModuleList ();
2013-12-22 21:03:21 +00:00
\Drupal :: service ( 'kernel' ) -> updateModules ( $module_filenames , $module_filenames );
2009-10-09 07:48:07 +00:00
return user_access ( 'administer software updates' );
}
2013-01-21 19:21:34 +00:00
catch ( \Exception $e ) {
2013-07-11 17:29:02 +00:00
return ( $user -> id () == 1 );
2009-10-09 07:48:07 +00:00
}
}
2007-03-02 09:40:27 +00:00
/**
2012-09-14 15:19:14 +00:00
* Adds the update task list to the current page .
2007-03-02 09:40:27 +00:00
*/
function update_task_list ( $active = NULL ) {
// Default list of tasks.
$tasks = array (
2009-05-09 18:35:01 +00:00
'requirements' => 'Verify requirements' ,
2007-03-02 09:40:27 +00:00
'info' => 'Overview' ,
2008-08-31 12:45:41 +00:00
'select' => 'Review updates' ,
2007-03-02 09:40:27 +00:00
'run' => 'Run updates' ,
'finished' => 'Review log' ,
);
2013-07-20 19:35:36 +00:00
$task_list = array (
'#theme' => 'task_list' ,
'#items' => $tasks ,
'#active' => $active ,
);
2014-04-17 20:12:22 +00:00
return $task_list ;
2007-03-02 09:40:27 +00:00
}
2006-03-11 13:45:41 +00:00
// Some unavoidable errors happen because the database is not yet up-to-date.
2006-04-11 11:33:15 +00:00
// Our custom error handler is not yet installed, so we just suppress them.
2006-03-01 22:19:24 +00:00
ini_set ( 'display_errors' , FALSE );
2009-05-09 18:35:01 +00:00
// We prepare a minimal bootstrap for the update requirements check to avoid
// reaching the PHP memory limit.
2014-06-05 17:53:24 +00:00
require_once __DIR__ . '/includes/bootstrap.inc' ;
2013-03-17 06:36:36 +00:00
require_once __DIR__ . '/includes/update.inc' ;
2014-06-05 17:53:24 +00:00
require_once __DIR__ . '/includes/common.inc' ;
require_once __DIR__ . '/includes/file.inc' ;
require_once __DIR__ . '/includes/unicode.inc' ;
2014-01-31 17:26:04 +00:00
require_once __DIR__ . '/includes/install.inc' ;
2014-06-05 17:53:24 +00:00
require_once __DIR__ . '/includes/schema.inc' ;
// Bootstrap to configuration.
drupal_bootstrap ( DRUPAL_BOOTSTRAP_CONFIGURATION );
2014-01-31 17:26:04 +00:00
2014-06-05 17:53:24 +00:00
// Bootstrap the database.
require_once __DIR__ . '/includes/database.inc' ;
2014-01-31 17:26:04 +00:00
// Updating from a site schema version prior to 8000 should block the update
// process. Ensure that the site is not attempting to update a database
// created in a previous version of Drupal.
if ( db_table_exists ( 'system' )) {
$system_schema = db_query ( 'SELECT schema_version FROM {system} WHERE name = :system' , array ( ':system' => 'system' )) -> fetchField ();
if ( $system_schema < \Drupal :: CORE_MINIMUM_SCHEMA_VERSION ) {
print 'Your system schema version is ' . $system_schema . '. Updating directly from a schema version prior to 8000 is not supported. You must <a href="https://drupal.org/node/2179269">migrate your site to Drupal 8</a> first.' ;
exit ;
}
}
2014-06-05 17:53:24 +00:00
// Enable UpdateServiceProvider service overrides.
// @see update_flush_all_caches()
$GLOBALS [ 'conf' ][ 'container_service_providers' ][ 'UpdateServiceProvider' ] = 'Drupal\Core\DependencyInjection\UpdateServiceProvider' ;
$GLOBALS [ 'conf' ][ 'update_service_provider_overrides' ] = TRUE ;
// module.inc is not yet loaded but there are calls to module_config_sort()
// below.
require_once __DIR__ . '/includes/module.inc' ;
$settings = Settings :: getAll ();
new Settings ( $settings );
$kernel = new DrupalKernel ( 'update' , drupal_classloader (), FALSE );
$kernel -> boot ();
$request = Request :: createFromGlobals ();
$container = \Drupal :: getContainer ();
$container -> set ( 'request' , $request );
$container -> get ( 'request_stack' ) -> push ( $request );
2011-02-21 20:05:26 +00:00
2009-05-09 18:35:01 +00:00
// Determine if the current user has access to run update.php.
2014-06-05 17:53:24 +00:00
drupal_bootstrap ( DRUPAL_BOOTSTRAP_PAGE_CACHE );
2014-04-10 17:30:54 +00:00
\Drupal :: service ( 'session_manager' ) -> initialize ();
2013-11-19 16:21:35 +00:00
2013-07-20 21:15:54 +00:00
// Ensure that URLs generated for the home and admin pages don't have 'update.php'
// in them.
2013-09-16 03:58:06 +00:00
$generator = \Drupal :: urlGenerator ();
2013-07-20 21:15:54 +00:00
$generator -> setBasePath ( str_replace ( '/core' , '' , $request -> getBasePath ()) . '/' );
$generator -> setScriptPath ( '' );
2012-04-26 04:37:14 +00:00
// There can be conflicting 'op' parameters because both update and batch use
// this parameter name. We need the 'op' coming from a POST request to trump
// that coming from a GET request.
$op = $request -> request -> get ( 'op' );
if ( is_null ( $op )) {
$op = $request -> query -> get ( 'op' );
}
2009-05-09 18:35:01 +00:00
// Only allow the requirements check to proceed if the current user has access
// to run updates (since it may expose sensitive information about the site's
// configuration).
2012-04-26 04:37:14 +00:00
if ( is_null ( $op ) && update_access_allowed ()) {
2013-05-09 09:25:10 +00:00
require_once __DIR__ . '/includes/install.inc' ;
2011-10-31 04:05:57 +00:00
require_once DRUPAL_ROOT . '/core/modules/system/system.install' ;
2008-01-16 10:37:43 +00:00
// Set up theme system for the maintenance page.
drupal_maintenance_theme ();
2011-10-01 16:11:43 +00:00
// Check the update requirements for Drupal. Only report on errors at this
// stage, since the real requirements check happens further down.
2014-01-31 17:26:04 +00:00
// The request will exit() if any requirement violations are reported in the
// following function invocation.
2011-10-01 16:11:43 +00:00
update_check_requirements ( TRUE );
2009-03-01 09:32:17 +00:00
2009-05-09 18:35:01 +00:00
// Redirect to the update information page if all requirements were met.
2011-10-31 04:05:57 +00:00
install_goto ( 'core/update.php?op=info' );
2008-01-16 10:37:43 +00:00
}
2006-03-28 09:29:23 +00:00
2014-06-05 17:53:24 +00:00
drupal_bootstrap ( DRUPAL_BOOTSTRAP_FULL );
2005-07-29 20:31:05 +00:00
drupal_maintenance_theme ();
2005-08-31 17:56:07 +00:00
2006-03-28 09:29:23 +00:00
// Turn error reporting back on. From now on, only fatal errors (which are
// not passed through the error handler) will cause a message to be printed.
ini_set ( 'display_errors' , TRUE );
2014-04-17 20:12:22 +00:00
$regions = array ();
2012-04-26 04:37:14 +00:00
2009-05-09 18:35:01 +00:00
// Only proceed with updates if the user is allowed to run them.
2009-10-09 07:48:07 +00:00
if ( update_access_allowed ()) {
2006-03-28 09:29:23 +00:00
2013-05-09 09:25:10 +00:00
include_once __DIR__ . '/includes/install.inc' ;
include_once __DIR__ . '/includes/batch.inc' ;
2006-07-31 19:24:16 +00:00
drupal_load_updates ();
2003-01-07 05:56:47 +00:00
2007-06-08 05:50:58 +00:00
update_fix_compatibility ();
2005-08-17 01:44:14 +00:00
2011-10-01 16:11:43 +00:00
// Check the update requirements for all modules. If there are warnings, but
// no errors, skip reporting them if the user has provided a URL parameter
// acknowledging the warnings and indicating a desire to continue anyway. See
// drupal_requirements_url().
2012-04-26 04:37:14 +00:00
$continue = $request -> query -> get ( 'continue' );
$skip_warnings = ! empty ( $continue );
2011-10-01 16:11:43 +00:00
update_check_requirements ( $skip_warnings );
2010-11-23 03:20:17 +00:00
2005-12-06 09:25:22 +00:00
switch ( $op ) {
2010-03-26 22:14:46 +00:00
// update.php ops.
2005-12-06 09:25:22 +00:00
2007-05-04 09:41:37 +00:00
case 'selection' :
2012-04-26 04:37:14 +00:00
$token = $request -> query -> get ( 'token' );
2012-04-16 19:38:32 +00:00
if ( isset ( $token ) && drupal_valid_token ( $token , 'update' )) {
2014-04-17 20:12:22 +00:00
$regions [ 'sidebar_first' ] = update_task_list ( 'select' );
2009-01-21 14:47:12 +00:00
$output = update_selection_page ();
break ;
}
2005-12-06 09:25:22 +00:00
2009-03-01 09:17:53 +00:00
case 'Apply pending updates' :
2012-04-26 04:37:14 +00:00
$token = $request -> query -> get ( 'token' );
2012-04-16 19:38:32 +00:00
if ( isset ( $token ) && drupal_valid_token ( $token , 'update' )) {
2014-04-17 20:12:22 +00:00
$regions [ 'sidebar_first' ] = update_task_list ( 'run' );
2011-10-01 16:11:43 +00:00
// Generate absolute URLs for the batch processing (using $base_root),
// since the batch API will pass them to url() which does not handle
// update.php correctly by default.
$batch_url = $base_root . drupal_current_script_url ();
$redirect_url = $base_root . drupal_current_script_url ( array ( 'op' => 'results' ));
Issue #1668866 by ParisLiakos, aspilicious, tim.plunkett, pdrake, g.oechsler, dawehner, Berdir, corvus_ch, damiankloip, disasm, marcingy, neclimdul: Replace drupal_goto() with RedirectResponse.
2013-06-19 16:07:30 +00:00
$output = update_batch ( $request -> request -> get ( 'start' ), $redirect_url , $batch_url );
2009-01-21 14:47:12 +00:00
break ;
}
case 'info' :
2014-04-17 20:12:22 +00:00
$regions [ 'sidebar_first' ] = update_task_list ( 'info' );
2009-01-21 14:47:12 +00:00
$output = update_info_page ();
2005-12-06 09:25:22 +00:00
break ;
2007-05-04 09:41:37 +00:00
case 'results' :
2014-04-17 20:12:22 +00:00
$regions [ 'sidebar_first' ] = update_task_list ();
2007-05-04 09:41:37 +00:00
$output = update_results_page ();
2005-12-06 09:25:22 +00:00
break ;
2010-03-26 22:14:46 +00:00
// Regular batch ops : defer to batch processing API.
2005-12-06 09:25:22 +00:00
default :
2014-04-17 20:12:22 +00:00
$regions [ 'sidebar_first' ] = update_task_list ( 'run' );
2013-09-15 06:52:34 +00:00
$output = _batch_page ( $request );
2005-12-06 09:25:22 +00:00
break ;
2002-05-15 22:36:30 +00:00
}
}
else {
2005-12-06 09:25:22 +00:00
$output = update_access_denied_page ();
2005-08-17 01:44:14 +00:00
}
2007-05-04 09:41:37 +00:00
if ( isset ( $output ) && $output ) {
2011-09-24 20:44:06 +00:00
// Explicitly start a session so that the update.php token will be accepted.
2014-04-10 17:30:54 +00:00
\Drupal :: service ( 'session_manager' ) -> start ();
2007-12-20 11:57:20 +00:00
// We defer the display of messages until all updates are done.
$progress_page = ( $batch = batch_get ()) && isset ( $batch [ 'running' ]);
2012-04-26 04:37:14 +00:00
if ( $output instanceof Response ) {
$output -> send ();
}
else {
2013-04-14 20:30:04 +00:00
drupal_add_http_header ( 'Content-Type' , 'text/html; charset=utf-8' );
2014-04-17 20:12:22 +00:00
print DefaultHtmlPageRenderer :: renderPage ( $output , $output [ '#title' ], 'maintenance' , $regions + array (
2013-07-20 19:35:36 +00:00
'#show_messages' => ! $progress_page ,
2014-04-17 20:12:22 +00:00
));
2012-04-26 04:37:14 +00:00
}
2006-03-14 21:19:41 +00:00
}