Updated to the Dev version recently so that I could apply a patch. Noticed that if I go to URLs that don't exist, I get a 503 Server Error (WDOD) instead of a 404 error. The error in the log is:
Symfony\Component\Routing\Exception\ResourceNotFoundException: No routes found for "/a". in Drupal\Core\Routing\Router->matchRequest() (line 125 of /home/vagrant/sites/solarwindsmsp/docroot/core/lib/Drupal/Core/Routing/Router.php).
This might to be related to using Custom Error pages and having the Global default canonical be set to [current-page:url:absolute].
The trace-back showed the root cause was from the use of Url::createFromRequest($request) in the token_tokens function. These calls should be wrapped in a try / catch with a fallback option and not cause a WSOD.
I found a work around by setting the custom error page nodes to use [site:url] for their canonical values.
Comments
Comment #2
berdirConfirmed, working on a fix and updating tests, but not quite sure how what the best way of getting the path is in case of an exception.
Comment #3
cgmonroe commentedSeems like if the path is not a Drupal route it should be the one from the request, e.g. Request::getRequestUri() (path / query only) or Request::getUri() (abs. path).
Comment #4
Anonymous (not verified) commentedPatch #2 applied to 8.x-1.2 fixes the problem for me. Thanks.
Comment #5
Adamation commentedI'm currently experiencing this issue on a production site.
I can't determine when I first noticed the issue.
Comment #6
sjancich commentedI got a variation of this error when installing a new site from a custom install profile. Patch #2 fixed it.
Comment #7
berdirImproved test coverage and also updated the second call to createFromRequest().
@cgmonroe: that's what the patch does, getPathInfo() is getRequestUri(), minus the base path.
Comment #9
berdirI don't know if this is the best fix, but it seems to work and is better than what we have now.
Comment #10
mxh commentedUnfortunately
Url::fromUserInputwould also throw an exception in case of urls likehttp://mysite/http://mysite/.Suggestions:
Why not using the request information directly when Url object instantiation fails? orUrl::fromRoute('<current>')instead of::fromUserInputas the comment would imply? Regardless the doc comment seems to be wrong, as the instruction is actually not directly using the<current>route.Comment #11
mxh commentedNot sure.
Comment #12
berdirforgot to update the comment. Problem is that
<current>is actually system/404 on a 404 page :)Comment #13
mxh commentedTrue, seems that Url::fromUserInput might be the only option we have here then.
Comment #14
berdirYeah. Can we extend the test coverage to cover this?
Not quite sure if we can trigger your case through a different URL in the existing UrlTest, maybe we could also do it in a kernel test?
Comment #15
mxh commentedAdded a first try for a kernel test. Maybe there's still some work needed regards consistency: the token replacement on "malformed" paths like
/https://drupal.org/would now result as empty, which is different for "non-malformed" paths where the response is a 404 page (for them, it seems the result would be/).Comment #18
mxh commentedSeems I'm not able to create a patch with new files. Making a Drupal patch with Git could not help me either :/
Comment #19
mxh commentedComment #21
berdirThanks, looks good to me.