? ?
avatar krileon
krileon
8 Jan 2021

Steps to reproduce the issue

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.

Expected result

Reach SEF routed URLs

Actual result

legacy_routing_issue

Additional comments

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.

avatar krileon krileon - open - 8 Jan 2021
avatar joomla-cms-bot joomla-cms-bot - change - 8 Jan 2021
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 8 Jan 2021
avatar chmst chmst - change - 9 Jan 2021
Labels Added: ?
avatar chmst chmst - labeled - 9 Jan 2021
avatar krileon
krileon - comment - 9 Jan 2021

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?

avatar Hackwar
Hackwar - comment - 17 Mar 2021

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.

avatar HLeithner HLeithner - change - 17 Mar 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-03-17 09:16:18
Closed_By HLeithner
Labels Added: ?
Removed: ?
avatar HLeithner HLeithner - close - 17 Mar 2021
avatar HLeithner
HLeithner - comment - 17 Mar 2021

As Hannes said

Add a Comment

Login with GitHub to post a comment