Problem:
In maintenance mode, users without the permission 'access site in maintenance mode' are logged out directly after login and should be redirected to the front page. This behaviour is broken so that an error occurs:
Symfony\Component\Routing\Exception\RouteNotFoundException: Route "/" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (Line 190 in .../core/lib/Drupal/Core/Routing/RouteProvider.php).
Steps to reproduce
- grant the permission 'access site in maintenance mode' to anonymous users
- revoke the permission 'access site in maintenance mode' from authenticated users
- create new user with no roles
- turn on maintenance mode
- login as the new user
Result
In dblog: Symfony\Component\Routing\Exception\RouteNotFoundException: Route "/" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (Line 190 in .../core/lib/Drupal/Core/Routing/RouteProvider.php).
Resolution:
In /core/modules/user/src/EventSubscriber/MaintenanceModeSubscriber.php, line 61, the method $this->url() is used unneccesarily because the redirect method already invokes the url function to resolve the given route:
$event->setResponse($this->redirect($this->url('<front>')));
Therefore, this line should read:
$event->setResponse($this->redirect('<front>'));