diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php index 2d1e88605fa5427a215320d3c253fc0169af2e53..ef54a705a0edb5e516fb980a9bbc4d0c9069f154 100644 --- a/core/modules/system/src/Controller/DbUpdateController.php +++ b/core/modules/system/src/Controller/DbUpdateController.php @@ -216,8 +216,10 @@ protected function info(Request $request) { ]; $info[] = $this->t("<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."); + // @todo Simplify with https://www.drupal.org/node/2548095 + $base_url = str_replace('/update.php', '', $request->getBaseUrl()); $info[] = $this->t('Put your site into <a href=":url">maintenance mode</a>.', [ - ':url' => Url::fromRoute('system.site_maintenance_mode')->toString(TRUE)->getGeneratedUrl(), + ':url' => Url::fromRoute('system.site_maintenance_mode')->setOption('base_url', $base_url)->toString(TRUE)->getGeneratedUrl(), ]); $info[] = $this->t('<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.'); $info[] = $this->t('Install your new files in the appropriate location, as described in the handbook.'); diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php index e129bfc6d6ab21fe16a53975cd5853c1aa063a08..d099edbe8b4e17fb86b214deae16f300bf0d9998 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php @@ -641,6 +641,23 @@ public function testSuccessfulMultilingualUpdateFunctionality() { $this->assertResponse(200); } + /** + * Tests maintenance mode link on update.php. + */ + public function testMaintenanceModeLink() { + $admin_user = $this->drupalCreateUser([ + 'administer software updates', + 'access administration pages', + 'administer site configuration', + ]); + $this->drupalLogin($admin_user); + $this->drupalGet($this->updateUrl, ['external' => TRUE]); + $this->assertResponse(200); + $this->clickLink('maintenance mode'); + $this->assertResponse(200); + $this->assertEquals('Maintenance mode', $this->cssSelect('main h1')[0]->getText()); + } + /** * Helper function to run updates via the browser. */