? ? Pending

User tests: Successful: Unsuccessful:

avatar wilsonge
wilsonge
12 Mar 2017

This is an attempt to fix the 404 issue in the router. Note that I have done very very limited testing but this puts it out there for us to all work with. This pulls the fix from the Joomla 4 branch and implements it in the 3 branch.

Note for the 404 to be fixed any component must have a sef_advanced parameter. Note that if the router only uses the "new" router then this can be a hidden parameter. The parameter just needs to exist otherwise the component will have the current 404 bug (I believe that this isn't a b/c issue as no extensions currently use the new router and this parameter will be removed in Joomla 4)

avatar wilsonge wilsonge - open - 12 Mar 2017
avatar wilsonge wilsonge - change - 12 Mar 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 12 Mar 2017
Category Libraries
avatar wilsonge wilsonge - change - 12 Mar 2017
Labels Added: ?
avatar zero-24
zero-24 - comment - 12 Mar 2017

@wilsonge

1) JRouterSiteTest::testParse with data set #3 ('/joomla/blog/test.json', 1, array(array('sef_suffix', null, '1')), array('', '', '', ''), array('json', 'com_test3', '45'), 'joomla/blog/test.json')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'joomla/blog/test.json'
+'joomla/blog/test'
/home/travis/build/joomla/joomla-cms/tests/unit/suites/libraries/cms/router/JRouterSiteTest.php:252
2) JRouterSiteTest::testParse with data set #4 ('/joomla/blog/test.json/', 1, array(array('sef_suffix', null, '1')), array('', '', '', ''), array('com_test3', '45'), 'joomla/blog/test.json')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'joomla/blog/test.json'
+'joomla/blog/test'
avatar joomla-cms-bot joomla-cms-bot - change - 12 Mar 2017
Category Libraries Libraries Unit Tests
avatar wilsonge wilsonge - change - 12 Mar 2017
Labels Added: ?
avatar Hackwar
Hackwar - comment - 12 Mar 2017
class plgSystemBreakit extends JPlugin {
	public function onAfterInitialise()
	{
		$router = JFactory::getApplication()->getRouter();
		$router->attachBuildRule(array($this, 'build'), PROCESS_AFTER);
		$router->attachParseRule(array($this, 'parse'), PROCESS_AFTER);
	}

	public function build($router, $uri)
	{
		if ($uri->hasVar('start')) {
			$uri->setPath($uri->getPath() . '/page-' . $uri->getVar('start'));
			$uri->delVar('start');
		}
	}

	public function parse($router, $uri)
	{
		$segments = explode('/', $uri->getPath());

		$last = end($segments);
		if (strpos($last, 'page-') === 0)
		{
			$uri->setVar('start', (int) str_replace($last, 'page-', ''));
		}
	}
}

This is just from the top of my head and not tested, but should show why the proposed code will break B/C. You don't get around deciding that behavior on a case by case basis.

avatar mbabker
mbabker - comment - 13 Mar 2017

The 4.0 backport is happening though after all the rules are run so that shouldn't be a problem? Otherwise in theory you've got this same issue with the plugin adding routing rules on the 4.0 branch.

avatar Hackwar
Hackwar - comment - 13 Mar 2017

The problem is not when the check is done, but that the check expects all parsed parts of the URL to be removed from the input. As you can see in my example above, that does not have to be the case.

avatar infograf768
infograf768 - comment - 17 Mar 2017

Works here when using experimental router for articles. No effect on stable router.

avatar wilsonge
wilsonge - comment - 20 Mar 2017

I'm merging this to make the conversation on routing move beyond this stupid 404 discussion. It's easy to hit the revert button if you guys have a huge issue with me merging my own code

avatar wilsonge wilsonge - close - 20 Mar 2017
avatar wilsonge wilsonge - merge - 20 Mar 2017
avatar wilsonge wilsonge - change - 20 Mar 2017
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2017-03-20 11:18:34
Closed_By wilsonge

Add a Comment

Login with GitHub to post a comment