diff --git a/core/includes/update.inc b/core/includes/update.inc index 7d3da06..5aff2bc 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -505,9 +505,17 @@ function update_do_one($module, $number, $dependency_map, &$context) { function update_batch($start, $redirect = NULL, $url = NULL, $batch = array(), $redirect_callback = 'drupal_goto') { // During the update, bring the site offline so that schema changes do not // affect visiting users. - $_SESSION['maintenance_mode'] = config('system.maintenance')->get('enabled'); - if ($_SESSION['maintenance_mode'] == FALSE) { - config('system.maintenance')->set('enabled', TRUE)->save(); + $maintenance_mode = config('system.maintenance')->get('enabled'); + if (isset($maintenance_mode)) { + $_SESSION['maintenance_mode'] = $maintenance_mode; + } + if (empty($_SESSION['maintenance_mode'])) { + $GLOBALS['conf']['system.maintenance']['enabled'] = TRUE; + // @todo This is borderline state, not config. Or a global system + // "maintenance lock". + if (db_table_exists('config')) { + config('system.maintenance')->set('enabled', TRUE)->save(); + } } // Resolve any update dependencies to determine the actual updates that will @@ -577,7 +585,9 @@ function update_finished($success, $results, $operations) { // Now that the update is done, we can put the site back online if it was // previously in maintenance mode. - if (isset($_SESSION['maintenance_mode']) && $_SESSION['maintenance_mode'] == FALSE) { + if (isset($_SESSION['maintenance_mode'])) { + $GLOBALS['conf']['system.maintenance']['enabled'] = FALSE; + // At this point, the configuration system should exist. config('system.maintenance')->set('enabled', FALSE)->save(); unset($_SESSION['maintenance_mode']); }