Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.0.0, 1.0.1
-
Fix Version/s: 1.6.0
-
Component/s: Zend_Controller
-
Labels:None
-
Fix Version Priority:Must Have
Description
I have a $this->_redirector->goto(null,null,'admin'); inside my Admin_ClassController->viewAction() ...
What is expected to happen here is for the page to redirect to http://example.com/admin but it goes to http://example.com/admin/class instead. Granted, you can do a $this->_redirector->goto(null,'index','admin'); but then you get http://example.com/admin/index (I'd prefer to not have the extra /index on the end).
Looks like a problem in Zend_Controller_Action_Helper_Redirector->setGoto(); ...
if (null === $controller) { $controller = $request->getControllerName(); if (empty($controller)) { $controller = $dispatcher->getDefaultControllerName(); } }
should be:
if (null === $controller) { if (null !== $action) { $controller = $request->getControllerName(); if (empty($controller)) { $controller = $dispatcher->getDefaultControllerName(); } } }
The addition checks to see if the $action was set, THEN we can get the controller name if $controller was not set - otherwise leave $controller as null.
I tested this change in my application and the problem was solved.
This also keeps the functionality consistent as you can now do $this->_redirector->goto(null); and be redirected to the current module index rather than the controller you are currently in.
UPDATE:
I have found another problem here...
When doing a $this->_redirector->goto(null,null,'default'); you end up with the URL http://example.com/default instead of the plain old http://example.com/. This is also the case when doing something like $this->_redirector->goto('login','account','default'); you will end up getting the URL http://example.com/default/account/login instead of http://example.com/account/login.
Here is the change to fix this issue (separate from the issue above). This code:
if (null === $module) { $module = $request->getModuleName(); if ($module == $dispatcher->getDefaultModule()) { $module = ''; } }
Should be:
if (null === $module) { $module = $request->getModuleName(); } if ($module == $dispatcher->getDefaultModule()) { $module = ''; }
This fixes the issues I am having with it. Comments anyone?
Assigning to
Matthew Weier O'Phinney to initiate issue review.