ZF-9800: Modules names cannot be hyphenated like controller and action names
Description
Based on the convention for translating URI paths to module/controller/action the following URI should work:
/foo-bar/index/index
However, this fails to route to the fooBar module and instead routes to the default module (if one is set). This is because internally the formatModuleName method of the Zend_Controller_Dispatcher_Standard class is not being used consistently.
A patch to rectify this behaviour is included below:
==== /library/Zend/Controller/Action/Helper/ViewRenderer.php ==== 225,226c225,229 < $request = $this->getRequest(); < $module = $request->getModuleName(); --- > $request = $this->getRequest(); > $dispatcher = $this->getFrontController()->getDispatcher(); > $module = $dispatcher->formatModuleName($request->getModuleName()); > $module[0] = strtolower($module[0]); > 228c231 < $module = $this->getFrontController()->getDispatcher()->getDefaultModule(); --- > $module = $dispatcher->getDefaultModule();
==== /library/Zend/Controller/Dispatcher/Standard.php ==== 376a377,378 > $module = $this->formatModuleName($module); > $module[0] = strtolower($module[0]); 402a405 > $module = $this->formatModuleName($module);
Comments
Posted by Ryan Lange (ryan.lange) on 2011-01-31T10:17:43.000+0000
Confirmed in 1.11.2, also.
Posted by Ryan Lange (ryan.lange) on 2011-02-01T09:06:59.000+0000
Here's a unified diff based on revision 23686:
Posted by Adam Lundrigan (adamlundrigan) on 2012-02-24T03:08:10.000+0000
Are there any BC implications with changing this now? It would be nice to have consistency in module/controller/action formatting, but I fear that there may be implementations which rely on the current behaviour and this change would break the routing to those modules.
Posted by Adam Lundrigan (adamlundrigan) on 2012-06-01T16:16:22.000+0000
Attached a patch implementing the fix + unit test
Posted by Adam Lundrigan (adamlundrigan) on 2012-06-01T23:40:51.000+0000
Fixed in trunk (1.12.0): r24861