diff --git a/src/Form/UpdateReady.php b/src/Form/UpdateReady.php index 5d872e729f598bab3b21eb047c4044f3f1127054..1a0d628a8daee63cf8027059ef52c3b0da4825f3 100644 --- a/src/Form/UpdateReady.php +++ b/src/Form/UpdateReady.php @@ -165,11 +165,14 @@ class UpdateReady extends FormBase { '#markup' => $this->t('Back up your database and site before you continue. <a href=":backup_url">Learn how</a>.', [':backup_url' => 'https://www.drupal.org/node/22281']), '#suffix' => '</strong>', ]; - $form['maintenance_mode'] = [ - '#title' => $this->t('Perform updates with site in maintenance mode (strongly recommended)'), - '#type' => 'checkbox', - '#default_value' => TRUE, - ]; + if (!$this->state->get('system.maintenance_mode')) { + $form['maintenance_mode'] = [ + '#title' => $this->t('Perform updates with site in maintenance mode (strongly recommended)'), + '#type' => 'checkbox', + '#default_value' => TRUE, + ]; + } + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Continue'), @@ -204,6 +207,7 @@ class UpdateReady extends FormBase { if ($form_state->getValue('maintenance_mode')) { $this->state->set('system.maintenance_mode', TRUE); } + $stage_id = $form_state->getValue('stage_id'); $batch = (new BatchBuilder()) ->setTitle($this->t('Apply updates')) diff --git a/tests/src/Functional/UpdaterFormTest.php b/tests/src/Functional/UpdaterFormTest.php index 69ffa8a87d5ce019056081a19fb4b829f822deca..cd1ec9b1299685c7dcb32e427086470f288df05f 100644 --- a/tests/src/Functional/UpdaterFormTest.php +++ b/tests/src/Functional/UpdaterFormTest.php @@ -413,7 +413,12 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { $possible_update_message = 'Possible database updates were detected in the following modules; you may be redirected to the database update page in order to complete the update process.'; $assert_session->pageTextContains($possible_update_message); $assert_session->pageTextContains('System'); - $assert_session->checkboxChecked('maintenance_mode'); + if ($maintenance_mode_on === TRUE) { + $assert_session->fieldNotExists('maintenance_mode'); + } + else { + $assert_session->checkboxChecked('maintenance_mode'); + } $assert_session->pageTextNotContains($cached_message); $page->pressButton('Continue'); $this->checkForMetaRefresh();