Problem/Motivation
When I enable maintenance mode on my website, anonymous users do not see the maintenance page.
I noticed that if maintenance mode is enabled, the `AnonymousLoginSubscriber` class is not called because the response is cached. Therefore, we need to clear the page cache when enabling maintenance mode.
Steps to reproduce
- Visit the site as an anonymous user.
- Log in using another browser and enable maintenance mode.
- Reload the page you visited in the first step (please ensure the URL does not point to the user/login path)
Result: You still see the login form.
Expected: You should see the maintaince page.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | anonymous.png | 194.96 KB | arunsahijpal |
| #6 | before.png | 186.5 KB | arunsahijpal |
| #6 | maintenance.png | 111.8 KB | arunsahijpal |
| #5 | Site-under-maintenance-DrupalPod.png | 69.29 KB | kanchan bhogade |
| #5 | Before.png | 79.04 KB | kanchan bhogade |
Issue fork anonymous_login-3500544
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
rajat4u commentedWorking on it.
Comment #4
rajat4u commentedComment #5
kanchan bhogade commentedHi
I've tested MR !15 on Drupal 11.x
Applied MR successfully...
Testing Steps:
Visit the site as an anonymous user.
Log in using another browser and enable maintenance mode.
Reload the page you visited in the first step (please ensure the URL does not point to the user/login path)
Manual Test Result:After MR, The maintenance page is appears and not showing any path to login (/user/login )
Attaching Screenshot
Keeping in review for code verification
Comment #6
arunsahijpal commentedGood work @rajat4u ,
I tested this issue on my local and by applying the MR the issue is completely resolved as maintenance page is shown without clearing the cache.
Attaching ss for reference.
Hence moving it to RTBC.
Thanks
Arun
Comment #9
anton4uk commentedThanks, @rajat4u and the testers. MR !15 fixes the reported steps, but I opened an alternative MR for the following reasons:
My MR adds a submit handler to the maintenance mode form. It clears http_response only when the setting changes. It leaves the subscriber and its constructor unchanged. It also adds a functional test that fails without the fix.
Note: setting maintenance mode from drush still needs drush cr, the same as in core.
Comment #11
anton4uk commentedMerged MR !23. Thanks @segi for the report, @rajat.dkte for the first MR, and @kanchan bhogade and @arunsahijpal for testing. MR !15 is closed.