|
|
|
Sorry, I can't agree with You. My bootstrap.php:
$frontController = Zend_Controller_Front::getInstance(); $frontController->throwExceptions(true); $frontController->setRouter($router); $frontController->setParam('noViewRenderer', true); $frontController->setParam('useDefaultControllerAlways', true); $frontController->setControllerDirectory('../application/modules/default/controllers'); $frontController->registerPlugin(...some plugins here...); $frontController->returnResponse(true); /My own class for handling headers./ And let's try my code, set $frontController->setParam('useDefaultControllerAlways', false); and go to http://domain/non/existent Now use default ZF code. $frontController->setParam('useDefaultControllerAlways', false); and go to http://domain/non/existent I have done exactly what you suggest: I used a stock ZF install, with only an IndexController and ErrorController defined, and set the useDefaultControllerAlways param to false. In such a case, passing an invalid controller correctly goes to the ErrorController. Toggling the flag to true, I correctly go to the IndexController. This is exactly the behavior that is expected.
That said, I think I know where the confusion lies: when an action is also provided via the URL. Let's look at the flow:
So, the useDefaultControllerAlways flag is doing exactly as it should. The problem is that there is an expectation that the action controller will fall back to a default action as well. And that's the real issue here. I'm re-opening the issue and noting that when the default controller is selected in such a case that the default action as defined in the dispatcher should also be utilized. It was some time ago when I reported this bug so I forgot real problem here was $router->removeDefaultRoutes(). What You said is valid for general, default routes. Could You please explain to me what exactly should happen if we changed ZF default routing?
Resolved in r12822 in trunk and r12823 in 1.7 release branch
I can confirm this. Removing the default routes, the error controller is never called. Changing "!empty($controller)" to "empty($controller)", as suggested by the bug reporter, fixed the issue for me too.
This bug is marked as resolved, but I can still reproduce it in the latest release (1.8.1). As reported by Marek, the problem happens when calling $router->removeDefaultRoutes(), and can be fixed by removing the "!" sign from within the "!empty($controller)" check.
|
||||||||||||||||||||||||||||||||||||||||||||||||||
The one issue I've had with this is if I set the parameter after dispatch() has already been called on the front controller – i.e., from a plugin. In such a case, by the time that routeStartup() has hit, pushing the parameters into the front controller will have no effect on the router or dispatcher. If this is what you are doing, you may need to push that setParam() into your bootstrap or index.php prior to calling dispatch().