Issue Type: Bug Created: 2009-12-21T06:58:05.000+0000 Last Updated: 2010-01-31T04:17:40.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)
Reporter: Ben Scholzen (dasprid) Assignee: Ben Scholzen (dasprid) Tags: - Zend_Controller
Related issues: Attachments: - ZF-8594.diff
In the interface definition of the router it is stated that an exception should be thrown when no route matches the request. Instead it is currently simply ignored, which leads the request to the default controller/action, instead of going to the error controller which could emit a 404 error then. This can surely only happen, when the default module route was removed, which is intendend when you only want your own routes to match to avoid duplicate content for search engines.
Posted by Ben Scholzen (dasprid) on 2009-12-21T07:15:49.000+0000
I've attached a patch for this issue, but there's a problem. By applying this patch, the following two tests in Zend_Controller_Router_RewriteTest are breaking:
Posted by Ben Scholzen (dasprid) on 2009-12-21T07:58:42.000+0000
Attached new patch which solves the problem with front controller and error handler plugin.
Posted by Ben Scholzen (dasprid) on 2009-12-21T08:00:16.000+0000
Assigned to Matthew for review.
Posted by Peter Moolenaar (petermoolenaar) on 2010-01-29T08:02:39.000+0000
Well, the assumption is incorrect.
I've used the default route in a chain, and that stopped working now.
Example.
host/AppPath/MyOwnFirstRouteThing/the/default/routing/should/apply
Either this fix is wrong, since the old behaviour was actually just like I expected it to work, or my approach is wrong and can be achieved otherwise. Maybe force default values to the 'default' route.
Posted by Ben Scholzen (dasprid) on 2010-01-29T08:51:53.000+0000
Peter, can you please tell, how exacly your chain setup looked (code?). The changes of this issue should not have affected stuff like you show here.
Posted by Peter Moolenaar (petermoolenaar) on 2010-01-30T08:22:04.000+0000
Yeah, based on the initial 'bug' and fix I also thought this would not affect stuff. However (and my chain is rather simple) it appears to influence some behaviour (maybe the problem lies within the incorrect chaining of the 'default' route... either way, below the code that fails (two methods to create the default route chained behind my own initial route included, both fail)
Maybe the matching algorithm of a default route doesn't return that it matched anything when chained this way??
// START CREATION OF OUR OWN SPECIALIZED ROUTER
// *************
$router = Zend_Controller_Front::getInstance()->getRouter();
// Create a very simple DB route that just matches the first part
$route = new Zend_Controller_Router_Route(':db');
// Create the 'default' route, it needs the dispatcher to function
$default = new Zend_Controller_Router_Rewrite();
$default = $default->addDefaultRoutes()->getRoute('default');
//Other method to create the default route (neither works)
/*
$request = Zend_Controller_Front::getInstance()->getRequest();
$dispatcher = Zend_Controller_Front::getInstance()->getDispatcher();
//$dispatcher = null;
$default = new Zend_Controller_Router_Route_Module(array(), $dispatcher, $request);
*/
// Create a chained route which should match <a rel="nofollow" href="http://foo.bar/basePath/DBVARIABLE[/[module]/controller">http://foo.bar/basePath/DBVARIABLE[/…</a>....]
$chain = $route->chain($default);
$router->addRoute('default', $chain);
// *************
// THE CREATION OF THE ROUTE ENDS HERE, however we continue below with some other init stuff
Posted by Ben Scholzen (dasprid) on 2010-01-30T09:36:23.000+0000
There already is a unittest covering exacly your example (tho using a static route, not a segment route):
Zend_Controller_Router_Route_ChainTest::testChainingModule()
Even modified to use a segment route instead it still passes, so it is most likely a problem with your setup. For further help, please ask in irc (freenode, #zftalk) or on the mailing list.
Posted by Peter Moolenaar (petermoolenaar) on 2010-01-30T12:49:29.000+0000
Ah, using Zend_Controller_Router_Route_Module() instead of extracting the 'default' works like it should. Next time I'll take a look at the unit tests first...
Although I'd still call it an regression issue :D
Posted by Peter Moolenaar (petermoolenaar) on 2010-01-30T14:35:34.000+0000
Hmm, I might have been a bit too optimistic about this... Still experiencing problems, I forgot to revert the quickfix I had done so it wouldn't throw the error.
I'll get back on this one.
Posted by Peter Moolenaar (petermoolenaar) on 2010-01-31T04:17:40.000+0000
The problem already existed in Chain but surfaced due to this fix. I've created a new issue for this one; ZF-9030