Skip to content

Commit

Permalink
Issue #2830326 by dww, mpdonadio, cebasqueira, Wim Leers, amateescu, …
Browse files Browse the repository at this point in the history
…jungle, xjm, daffie, Pasqualle: Broken link to 'Put your site into maintenance mode' on update.php results in WSOD

(cherry picked from commit 240e303d6afea84fc713b8131fdf5ee98443e22e)
  • Loading branch information
alexpott committed May 21, 2020
1 parent c9cae03 commit 7c5bfa0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/system/src/Controller/DbUpdateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 7c5bfa0

Please sign in to comment.