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>'));
| Comment | File | Size | Author |
|---|---|---|---|
| Broken_redirect_after_login_in_maintenance_mode.patch | 762 bytes | boogiewoogieman |
Comments
Comment #2
boogiewoogieman commentedComment #3
cilefen commentedComment #4
tr commentedI was able to reproduce this without first two steps of granting/revoking a permission. That is, all you have to do is:
The error then shows up in the dblog. The user won't see the error - it just shows up in the dblog. The user is correctly redirected to the maintenance page.
I reviewed the patch. It is correct and does solve the problem. However I think there should be a test case to prevent the problem from reoccuring.
Comment #5
cilefen commentedComment #6
joelstein commentedSame issue here and patch fixed it for me.
Comment #7
Anonymous (not verified) commentedFix #3001309: Replace usages of UrlGeneratorTrait in non-api classes
Leaving Active.
Comment #8
s.messaris commentedSince there is a patch and tests are missing, I'm adding the "needs tests" tag and changing status to "needs work".
Comment #9
aron.beal commentedJust a note on this: I think the patch is correct, but the behavior once it is fixed if no home page is provided is to redirect back to the login page immediately, with no message to the user as to what went wrong. I'm not sure if this is the correct venue for this (versus a separate issue), but I wanted to mention it.
Comment #10
olafkarsten commentedIssue is fixed with #3001309: Replace usages of UrlGeneratorTrait in non-api classes
Not sure if we really need a test here.
Comment #19
danielvezaConfirming that @olafkarsten is correct and this error has been resolved.
Tried to replicate by:
No errors/warnings thrown. I think this can be closed. Leaving it as postponed for a second opinion.