diff --git a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php
index 0af47876e7..0f8283184f 100644
--- a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php
@@ -127,15 +127,23 @@ public function onKernelRequestMaintenance(RequestEvent $event) {
$this->eventDispatcher->dispatch($event, MaintenanceModeEvents::MAINTENANCE_MODE_REQUEST);
}
else {
- // Display a message if the logged in user has access to the site in
- // maintenance mode. However, suppress it on the maintenance mode
- // settings page.
+ // Display a message if the logged-in user has access to the site in
+ // maintenance mode. Don't show maintenance message:
+ // - on AJAX requests.
+ // - on Iframe uploads.
+ // - on the maintenance mode settings page.
if ($route_match->getRouteName() != 'system.site_maintenance_mode') {
- if ($this->account->hasPermission('administer site configuration')) {
- $this->messenger->addMessage($this->t('Operating in maintenance mode. Go online.', [':url' => $this->urlGenerator->generate('system.site_maintenance_mode')]), 'status', FALSE);
- }
- else {
- $this->messenger->addMessage($this->t('Operating in maintenance mode.'), 'status', FALSE);
+ $show_message = $route_match->getRouteName() != 'system.site_maintenance_mode' &&
+ !$event->getRequest()->isXmlHttpRequest() &&
+ $event->getRequest()->get('ajax_iframe_upload', FALSE) === FALSE;
+
+ if ($show_message) {
+ if ($this->account->hasPermission('administer site configuration')) {
+ $this->messenger->addMessage($this->t('Operating in maintenance mode. Go online.', [':url' => $this->urlGenerator->generate('system.site_maintenance_mode')]), 'status', FALSE);
+ }
+ else {
+ $this->messenger->addMessage($this->t('Operating in maintenance mode.'), 'status', FALSE);
+ }
}
}
}
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/FileWidgetTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/FileWidgetTest.php
new file mode 100644
index 0000000000..9ffabb32a7
--- /dev/null
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/FileWidgetTest.php
@@ -0,0 +1,96 @@
+adminUser = $this->drupalCreateUser([
+ 'access content',
+ 'access administration pages',
+ 'administer site configuration',
+ 'access site in maintenance mode',
+ 'bypass node access',
+ ]);
+ $this->drupalLogin($this->adminUser);
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
+ }
+
+ /**
+ * Tests uploading and remove buttons for a single-valued File field.
+ */
+ public function testSingleValuedWidget() {
+ $page = $this->getSession()->getPage();
+ $assert_session = $this->assertSession();
+ $type_name = 'article';
+ $field_name = 'test_file_field_1';
+ $cardinality = 1;
+
+ // Turn on maintenance mode.
+ $edit = [
+ 'maintenance_mode' => 1,
+ ];
+ $this->drupalGet('admin/config/development/maintenance');
+ $this->submitForm($edit, 'Save configuration');
+
+ $this->createFileField($field_name, 'node', $type_name, ['cardinality' => $cardinality]);
+
+ $test_file = current($this->getTestFiles('text'));
+ $test_file_path = \Drupal::service('file_system')
+ ->realpath($test_file->uri);
+
+ $this->drupalGet("node/add/$type_name");
+ $page->findField('title[0][value]')->setValue($this->randomString());
+ $page->attachFileToField('files[' . $field_name . '_0]', $test_file_path);
+ $remove_button = $assert_session->waitForElementVisible('css', '[name="' . $field_name . '_0_remove_button"]');
+ $this->assertNotNull($remove_button);
+ $remove_button->click();
+ $upload_field = $assert_session->waitForElementVisible('css', 'input[type="file"]');
+ $this->assertNotEmpty($upload_field);
+ $page->attachFileToField('files[' . $field_name . '_0]', $test_file_path);
+ $remove_button = $assert_session->waitForElementVisible('css', '[name="' . $field_name . '_0_remove_button"]');
+ $this->assertNotNull($remove_button);
+
+ $this->assertSession()->assertWaitOnAjaxRequest();
+ $this->assertSession()->pageTextContainsOnce('Operating in maintenance mode');
+
+ $page->pressButton('Save');
+ $page->hasContent($test_file->name);
+ }
+
+}