diff --git a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php index bdd05c7..d9d51fe 100644 --- a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php @@ -102,7 +102,7 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) { // Deliver the 503 page if the site is in maintenance mode and the // logged in user is not allowed to bypass it. drupal_maintenance_theme(); - $content = Xss::filterAdmin(String::format($this->config->get('system.maintenance')->get('message'), array( + $content = Xss::filterAdmin(String::format($this->config->getEditable('system.maintenance')->get('message'), array( '@site' => $this->config->get('system.site')->get('name'), ))); $output = $this->bareHtmlPageRenderer->renderBarePage(['#markup' => $content], $this->t('Site under maintenance'), 'maintenance_page'); diff --git a/core/modules/system/src/Tests/System/SiteMaintenanceTest.php b/core/modules/system/src/Tests/System/SiteMaintenanceTest.php index 48c592d..046bd2f 100644 --- a/core/modules/system/src/Tests/System/SiteMaintenanceTest.php +++ b/core/modules/system/src/Tests/System/SiteMaintenanceTest.php @@ -21,7 +21,7 @@ class SiteMaintenanceTest extends WebTestBase { * * @var array */ - public static $modules = array('node'); + public static $modules = array('node', 'locale'); protected $admin_user; @@ -34,7 +34,7 @@ protected function setUp() { // Create a user allowed to access site in maintenance mode. $this->user = $this->drupalCreateUser(array('access site in maintenance mode')); // Create an administrative user. - $this->admin_user = $this->drupalCreateUser(array('administer site configuration', 'access site in maintenance mode')); + $this->admin_user = $this->drupalCreateUser(array('administer site configuration', 'access site in maintenance mode', 'translate interface', 'administer languages')); $this->drupalLogin($this->admin_user); } @@ -50,6 +50,7 @@ function testSiteMaintenance() { $admin_message = t('Operating in maintenance mode. Go online.', array('@url' => \Drupal::url('system.site_maintenance_mode'))); $user_message = t('Operating in maintenance mode.'); + $custom_user_message = t('Deze site is in onderhoud.'); $offline_message = t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => $this->config('system.site')->get('name'))); $this->drupalGet(''); @@ -112,5 +113,32 @@ function testSiteMaintenance() { // Log in with temporary login link. $this->drupalPostForm($path, array(), t('Log in')); $this->assertText($user_message); + + $this->drupalLogout(); + $this->drupalLogin($this->admin_user); + + $langcode = 'es'; + + // Add Spanish. + $edit = array(); + $edit['predefined_langcode'] = $langcode; + $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); + + // Make Dutch the default language. + $edit = array(); + $edit['site_default_language'] = 'nl'; + $this->drupalPostForm(NULL, $edit, t('Save configuration')); + + // Set a custom Dutch maintenance message. + $edit = array( + 'maintenance_mode' => 1, + 'maintenance_mode_message' => $custom_user_message, + ); + $this->drupalPostForm('admin/config/development/maintenance', $edit, t('Save configuration')); + + // Logout and verify that custom site offline message is displayed. + $this->drupalLogout(); + $this->drupalGet(''); + $this->assertRaw($offline_message, 'Found the site offline message.'); } }