diff --git a/core/cron.php b/core/cron.php index 126d991..4fb6834 100644 --- a/core/cron.php +++ b/core/cron.php @@ -20,7 +20,7 @@ if (!isset($_GET['cron_key']) || variable_get('cron_key', 'drupal') != $_GET['cr watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE); drupal_access_denied(); } -elseif (config('system.maintenance')->get('maintenance_mode')) { +elseif (config('system.maintenance')->get('mode')) { watchdog('cron', 'Cron could not run because the site is in maintenance mode.', array(), WATCHDOG_NOTICE); drupal_access_denied(); } diff --git a/core/includes/ajax.inc b/core/includes/ajax.inc index 328f54c..5978b27 100644 --- a/core/includes/ajax.inc +++ b/core/includes/ajax.inc @@ -515,8 +515,7 @@ function ajax_prepare_response($page_callback_result) { break; case MENU_SITE_OFFLINE: - $commands[] = ajax_command_alert(filter_xss_admin(variable_get('maintenance_mode_message', - t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => config('system.site')->get('name')))))); + $commands[] = ajax_command_alert(filter_xss_admin(t(config('system.maintenance')->get('message'), array('@site' => config('system.site')->get('name'))))); break; } } diff --git a/core/includes/common.inc b/core/includes/common.inc index 0b95dcd..f743121 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -2550,8 +2550,7 @@ function drupal_deliver_html_page($page_callback_result) { drupal_maintenance_theme(); drupal_add_http_header('Status', '503 Service unavailable'); drupal_set_title(t('Site under maintenance')); - print theme('maintenance_page', array('content' => filter_xss_admin(variable_get('maintenance_mode_message', - t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => $site_config->get('name'))))))); + print theme('maintenance_page', array('content' => filter_xss_admin(t(config('system.maintenance')->get('message'), array('@site' => $site_config->get('name')))))); break; } } diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 60b2bbe..ce07490 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -3789,7 +3789,7 @@ function _menu_router_save($menu, $masks) { */ function _menu_site_is_offline($check_only = FALSE) { // Check if site is in maintenance mode. - if (config('system.maintenance')->get('maintenance_mode')) { + if (config('system.maintenance')->get('mode')) { if (user_access('access site in maintenance mode')) { // Ensure that the maintenance mode message is displayed only once // (allowing for page redirects) and specifically suppress its display on diff --git a/core/includes/update.inc b/core/includes/update.inc index 303b2b0..ce2502e 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -519,9 +519,9 @@ 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('maintenance_mode'); + $_SESSION['maintenance_mode'] = config('system.maintenance')->get('mode'); if ($_SESSION['maintenance_mode'] == FALSE) { - config('system.maintenance')->set('maintenance_mode', TRUE)->save(); + config('system.maintenance')->set('mode', TRUE)->save(); } // Resolve any update dependencies to determine the actual updates that will @@ -592,7 +592,7 @@ 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) { - config('system.maintenance')->set('maintenance_mode', FALSE)->save(); + config('system.maintenance')->set('mode', FALSE)->save(); unset($_SESSION['maintenance_mode']); } } diff --git a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php index 6485fa1..d4eabfb 100644 --- a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php @@ -39,7 +39,7 @@ class MaintenanceModeSubscriber implements EventSubscriberInterface { // Deliver the 503 page. drupal_maintenance_theme(); drupal_set_title(t('Site under maintenance')); - $content = theme('maintenance_page', array('content' => filter_xss_admin(variable_get('maintenance_mode_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => config('system.site')->get('name'))))))); + $content = theme('maintenance_page', array('content' => filter_xss_admin(t(config('system.maintenance')->get('message'), array('@site' => config('system.site')->get('name')))))); $response = new Response('Service unavailable', 503); $response->setContent($content); $event->setResponse($response); diff --git a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php index 417487e..b84feaf 100644 --- a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php +++ b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php @@ -189,7 +189,7 @@ class OpenIDFunctionalTest extends OpenIDTestBase { $this->drupalLogout(); // Enable maintenance mode. - config('system.maintenance')->set('maintenance_mode', TRUE)->save(); + config('system.maintenance')->set('mode', TRUE)->save(); // Test logging in via the user/login page while the site is offline. $edit = array('openid_identifier' => $identity); diff --git a/core/modules/openid/openid.test b/core/modules/openid/openid.test index 06411a4..59066a2 100644 --- a/core/modules/openid/openid.test +++ b/core/modules/openid/openid.test @@ -247,7 +247,7 @@ class OpenIDFunctionalTestCase extends OpenIDWebTestCase { $this->drupalLogout(); // Enable maintenance mode. - config('system.maintenance')->set('maintenance_mode', TRUE)->save(); + config('system.maintenance')->set('mode', TRUE)->save(); // Test logging in via the user/login page while the site is offline. $edit = array('openid_identifier' => $identity); diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 45ad10e..209fd0f 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -2231,19 +2231,36 @@ function system_date_time_lookup() { * @see system_settings_form() */ function system_site_maintenance_mode() { - $form['maintenance_mode'] = array( + $config = config('system.maintenance'); + + $form['maintenance_mode'] = array( '#type' => 'checkbox', '#title' => t('Put site into maintenance mode'), - '#default_value' => variable_get('maintenance_mode', 0), + '#default_value' => $config->get('mode'), '#description' => t('Visitors will only see the maintenance mode message. Only users with the "Access site in maintenance mode" permission will be able to access the site. Authorized users can log in directly via the user login page.', array('@permissions-url' => url('admin/config/people/permissions'), '@user-login' => url('user'))), ); $form['maintenance_mode_message'] = array( '#type' => 'textarea', '#title' => t('Message to display when in maintenance mode'), - '#default_value' => variable_get('maintenance_mode_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => config('system.site')->get('name')))), + '#default_value' => $config->get('message'), ); - return system_settings_form($form); + $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration')); + return $form; +} + +/** + * Form builder submit handler. Handle submission for site maintenance settings. + * + * @ingroup forms + * @see system_settings_form() + */ +function system_site_maintenance_mode_submit($form, &$form_state) { + $config = config('system.maintenance'); + $config->set('mode', $form_state['values']['maintenance_mode']); + $config->set('message', $form_state['values']['maintenance_mode_message']); + $config->save(); + drupal_set_message(t('The configuration has been saved.')); } /** diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 2ca2db0..ca58916 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1182,7 +1182,7 @@ function system_cron_access($key) { watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE); return FALSE; } - elseif (config('system.maintenance')->get('maintenance_mode')) { + elseif (config('system.maintenance')->get('mode')) { watchdog('cron', 'Cron could not run because the site is in maintenance mode.', array(), WATCHDOG_NOTICE); return FALSE; } diff --git a/core/modules/update/update.authorize.inc b/core/modules/update/update.authorize.inc index 2ff5d40..2f7bc2b 100644 --- a/core/modules/update/update.authorize.inc +++ b/core/modules/update/update.authorize.inc @@ -190,7 +190,7 @@ function update_authorize_update_batch_finished($success, $results) { $success = FALSE; } } - $offline = config('system.maintenance')->get('maintenance_mode'); + $offline = config('system.maintenance')->get('mode'); if ($success) { // Now that the update completed, we need to clear the cache of available // update data and recompute our status, so prevent show bogus results. @@ -198,7 +198,7 @@ function update_authorize_update_batch_finished($success, $results) { // Take the site out of maintenance mode if it was previously that way. if ($offline && isset($_SESSION['maintenance_mode']) && $_SESSION['maintenance_mode'] == FALSE) { - config('system.maintenance')->set('maintenance_mode', FALSE)->save(); + config('system.maintenance')->set('mode', FALSE)->save(); $page_message = array( 'message' => t('Update was completed successfully. Your site has been taken out of maintenance mode.'), 'type' => 'status', @@ -257,11 +257,11 @@ function update_authorize_install_batch_finished($success, $results) { $success = FALSE; } } - $offline = config('system.maintenance')->get('maintenance_mode'); + $offline = config('system.maintenance')->get('mode'); if ($success) { // Take the site out of maintenance mode if it was previously that way. if ($offline && isset($_SESSION['maintenance_mode']) && $_SESSION['maintenance_mode'] == FALSE) { - config('system.maintenance')->set('maintenance_mode', FALSE)->save(); + config('system.maintenance')->set('mode', FALSE)->save(); $page_message = array( 'message' => t('Installation was completed successfully. Your site has been taken out of maintenance mode.'), 'type' => 'status', diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc index 54184fb..5ab1234 100644 --- a/core/modules/update/update.manager.inc +++ b/core/modules/update/update.manager.inc @@ -423,9 +423,9 @@ function update_manager_update_ready_form($form, &$form_state) { */ function update_manager_update_ready_form_submit($form, &$form_state) { // Store maintenance_mode setting so we can restore it when done. - $_SESSION['maintenance_mode'] = config('system.maintenance')->get('maintenance_mode'); + $_SESSION['maintenance_mode'] = config('system.maintenance')->get('mode'); if ($form_state['values']['maintenance_mode'] == TRUE) { - config('system.maintenance')->set('maintenance_mode', TRUE)->save(); + config('system.maintenance')->set('mode', TRUE)->save(); } if (!empty($_SESSION['update_manager_update_projects'])) {