From 240e303d6afea84fc713b8131fdf5ee98443e22e Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Thu, 21 May 2020 09:26:01 +0100 Subject: [PATCH] Issue #2830326 by dww, mpdonadio, cebasqueira, Wim Leers, amateescu, jungle, xjm, daffie, Pasqualle: Broken link to 'Put your site into maintenance mode' on update.php results in WSOD --- .../src/Controller/DbUpdateController.php | 4 +++- .../UpdateSystem/UpdateScriptTest.php | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php index 2d1e88605fa5..ef54a705a0ed 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 e129bfc6d6ab..d099edbe8b4e 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. */ -- GitLab