Maintenance Mode message is shown at multiple places on the page on Form API Ajax Callbacks

Created on 13 May 2016, over 8 years ago
Updated 24 April 2023, over 1 year ago

Problem/Motivation

Duplicate maintenance mode message displayed.

Steps to reproduce

  1. On any content type that has a simple file field, create a node with an attachment file.
  2. Put the site in maintenance mode.
  3. Edit the node and remove the file attachment by clicking on the "Remove" button beside the file.
  4. Now when the file is removed, the form has the "Operating in maintenance mode. Go Online" message at 2 more places on the form, apart from the usual top message.

Proposed resolution

Display on one message, at the top of the screen.

Remaining tasks




Review

User interface changes

Before

After

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

🐛 Bug report
Status

Fixed

Version

10.0

Component
Base 

Last updated about 13 hours ago

Created by

🇮🇳India saitanay

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇳China jungle Chongqing, China
    +++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxMaintenanceModeTest.php
    @@ -0,0 +1,96 @@
    +class AjaxMaintenanceModeTest extends WebDriverTestBase {
    

    Agree with @alexpott in #40,and the test could be simplified by using ajax_test, ajax_form_test.

  • Status changed to Needs work almost 2 years ago
  • 🇺🇸United States smustgrave

    Will give it another shot but was having issues with those test modules

    Thanks!

  • Status changed to Needs review over 1 year ago
  • 🇺🇸United States smustgrave

    Fixed up tests.

  • 🇮🇳India TanujJain-TJ

    Tested and verified patch #51 with drupal: 10.1.x and the patch applied successfully and fixed the issue of multiple message on page. adding screenshots for reference. RTBC+1

  • 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
    +++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxMaintenanceModeTest.php
    @@ -0,0 +1,72 @@
    +    // Turn on maintenance mode.
    +    $edit = [
    +      'maintenance_mode' => 1,
    +    ];
    +    $this->drupalGet('admin/config/development/maintenance');
    +    $this->submitForm($edit, 'Save configuration');
    

    Micro-optimisation, but I think we can enable this by setting the flag direct in state rather than needing to submit the form, will save a few HTTP requests and speed up the test

    Other than that, makes sense to me

  • 🇺🇸United States smustgrave

    Updated.

  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,284 pass
  • 🇺🇸United States dww

    The test-only patch is failing exactly as expected:

    1) Drupal\FunctionalJavascriptTests\Ajax\AjaxMaintenanceModeTest::testAjaxCallMaintenanceMode
    Behat\Mink\Exception\ResponseTextException: Failed asserting that the page matches the pattern '/Operating in maintenance mode/ui' 1 time(s), 2 found.
    Failed asserting that 2 is identical to 1.
    

    I closely reviewed the code here. Almost all looked great. Found a couple of very trivial nits. Fixing those as a new patch and RTBC'ing.

  • Status changed to RTBC over 1 year ago
  • 🇺🇸United States dww
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    9:21
    5:42
    Running
  • Open in Jenkins → Open on Drupal.org →
    Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    29,303 pass
    • catch committed dbd61328 on 10.1.x
      Issue #2724829 by smustgrave, aneek, dww, saitanay, alexpott, quietone,...
  • Status changed to Fixed over 1 year ago
  • 🇬🇧United Kingdom catch

    Committed dbd6132 and pushed to 10.1.x. Thanks!

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍
    diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxMaintenanceModeTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxMaintenanceModeTest.php
    index 4d4d72b8ad..335557cdba 100644
    --- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxMaintenanceModeTest.php
    +++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxMaintenanceModeTest.php
    @@ -18,13 +18,6 @@ class AjaxMaintenanceModeTest extends WebDriverTestBase {
       use FileFieldCreationTrait;
       use TestFileCreationTrait;
     
    -  /**
    -   * An user with administration permissions.
    -   *
    -   * @var \Drupal\user\UserInterface
    -   */
    -  protected $adminUser;
    -
       /**
        * {@inheritdoc}
        */
    @@ -40,26 +33,22 @@ class AjaxMaintenanceModeTest extends WebDriverTestBase {
        */
       protected function setUp(): void {
         parent::setUp();
    -    $this->adminUser = $this->drupalCreateUser([
    +    $this->drupalLogin($this->drupalCreateUser([
           'access administration pages',
           'administer site configuration',
           'access site in maintenance mode',
    -    ]);
    -    $this->drupalLogin($this->adminUser);
    +    ]));
       }
     
       /**
        * Tests maintenance message only appears once on an AJAX call.
        */
       public function testAjaxCallMaintenanceMode(): void {
    -    $page = $this->getSession()->getPage();
    -    $assert_session = $this->assertSession();
    -
         \Drupal::state()->set('system.maintenance_mode', TRUE);
     
         $this->drupalGet('ajax-test/insert-inline-wrapper');
    -    $assert_session->pageTextContains('Target inline');
    -    $page->clickLink('Link html pre-wrapped-div');
    +    $this->assertSession()->pageTextContains('Target inline');
    +    $this->clickLink('Link html pre-wrapped-div');
         $this->assertSession()->assertWaitOnAjaxRequest();
         $this->assertSession()->pageTextContainsOnce('Operating in maintenance mode');
       }
    
    

    I was going to make the above changes on commit. Not important enough to do a revert but maybe someone wants to do a followup. We don't need the adminUser variable on test object and the $page and $assert_session variables are unnecessary and not even used consistently.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024