User tests: Successful: Unsuccessful:
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)
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
Category | Libraries | ⇒ | Libraries Unit Tests |
Labels |
Added:
?
|
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.
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.
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.
Works here when using experimental router for articles. No effect on stable router.
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
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-03-20 11:18:34 |
Closed_By | ⇒ | wilsonge |
@wilsonge