Subscribe to MaintenanceModeEvents::MAINTENANCE_MODE_REQUEST events

Created on 19 June 2024, 5 months ago
Updated 20 June 2024, 5 months ago

The \Drupal\Core\EventSubscriber\MaintenanceModeSubscriber class creates a MaintenanceModeEvents::MAINTENANCE_MODE_REQUEST event when the maintenance_mode service detects when the site is in maintenance mode and the currently logged in is not allowed to access the site when it is in maintenance mode.
This module should subscribe to MaintenanceModeEvents::MAINTENANCE_MODE_REQUEST events. In this way, it does not need to verify the site is in maintenance mode and the logged-in user is allowed to access the site.

This is a bug because modules can replace the maintenance_mode service implementation, which means the conditions for which a site is is in maintenance mode or for which a user has access to the site in maintenance mode could be different from the conditions the module assumes.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇮🇹Italy apaderno Brescia, 🇮🇹

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

Comments & Activities

  • Issue created by @apaderno
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Actually, to redirect users when the maintenance mode is enabled, the module should subscribe to a different event, which is created when a site is in maintenance mode and the logged-in user is not allowed to access a site in maintenance mode. This simplifies the code, as the event subscriber can be sure those conditions are met.

Production build 0.71.5 2024