ZF-6025: Redirector Helper contains hardcoded action/module/controller parameters

Description

I have implemented a custom routing and my action parameter isn't "action" but something different. This is all handled inside my routing stuff and works just fine. Unfortunately the redirector helper is hardcoded to "action" in setGotoSimple().

The following patch fixes it for me:


--- a/wcp/3rd/Zend/Controller/Action/Helper/Redirector.php
+++ b/wcp/3rd/Zend/Controller/Action/Helper/Redirector.php
@@ -269,9 +269,9 @@ class Zend_Controller_Action_Helper_Redirector extends Zend_Controller_Action_He
             }
         }

-        $params['module']     = $module;
-        $params['controller'] = $controller;
-        $params['action']     = $action;
+        $params[Zend_Controller_Front::getInstance()->getRequest()->getModuleKey()]     = $module;
+        $params[Zend_Controller_Front::getInstance()->getRequest()->getControllerKey()] = $controller;
+        $params[Zend_Controller_Front::getInstance()->getRequest()->getActionKey()]     = $action;

         $router = $this->getFrontController()->getRouter();
         $url    = $router->assemble($params, 'default', true);

I just started with Zend Framework and this might not be the best fix but it works for me ;) But i am sure you get the problem i am facing.

Comments

Good one, I think the patch looks good. Perhaps FC should'nt come from the singleton but from the Controller.

this (quite easyly fixable) bug is in here since 2 years and i still have to apply my fix for every ZF Update. Could somebody please fix that? :|

Add patch

Seems like a good, straightforward fix to me. My only reservation is that it changes the expected behavior of that function, so I would like to see a member of the ZF team comment on the change. That said, in my eyes, it's an internal process that applications built upon ZF shouldn't be depending directly on, so I don't see possibility of a BC break here.

One suggestion: Use $this->getFrontController() instead of Zend_Controller_Front::getInstance() to maintain consistency with the rest of the class.

bq. One suggestion: Use $this->getFrontController() instead of Zend_Controller_Front::getInstance() to maintain consistency with the rest of the class.

The patch does not call Zend_Controller_Front::getInstance(). The Request object is already available there and it has been used to get module, controller, action key names.

@Kim: Apologies. I was looking at the bug description, not the attached patch file.

Patch reviewed and applied to trunk and 1.11 release branch.