Install any Joomla 3.x extension with old router.php routing which is extending JComponentRouterBase that is not utilizing the advanced routing that was implemented primarily in com_content.
Reach SEF routed URLs
This is due to the following change in libraries/src/Router/Router.php for parse
function.
FROM:
// Check if all parts of the URL have been parsed.
// Otherwise we have an invalid URL
if (strlen($uri->getPath()) > 0 && array_key_exists('option', $vars)
&& ComponentHelper::getParams($vars['option'])->get('sef_advanced', 0))
{
throw new RouteNotFoundException('URL invalid');
}
TO:
// Check if all parts of the URL have been parsed.
// Otherwise we have an invalid URL
if (\strlen($uri->getPath()) > 0)
{
throw new RouteNotFoundException(Text::_('JERROR_PAGE_NOT_FOUND'));
}
The routing still works perfectly fine. Removing that code block allows the legacy routes to be resolved fine. SiteRouter is aware it's a LegacyComponent using RouterLegacy, but the Router class doesn't seam to take this into account for parse
.
Labels |
Added:
?
|
Labels |
Added:
?
|
Yes, this is indeed expected behavior. The idea is, that the router consumes the path while it parses it, until there is nothing left. If there is something left however at the end of the parsing, we have an invalid URL, which we couldn't match to anything and thus we need to throw a 404. Otherwise you could have for example domain.tld/validurl and simply extend it to domain.tld/validurl/somethingelse and would still get the content of domain.tld/validurl. It is a long standing request that Joomla throws proper 404 errors for URLs instead of creating "duplicate content" URLs.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-03-17 09:16:18 |
Closed_By | ⇒ | HLeithner | |
Labels |
Added:
?
Removed: ? |
As Hannes said
In the legacy router.php usage of ->parse setting $segments to an empty array once done parsing it resolves the issue. I'm fine with needing to do this, but is this expected behavior? Should the old IF check be used if a legacy router is being used?