ZF-12302: Zend_Controller_Action::_forward() causes infinite loop

Description

Marked as minor due to relatively simple workaround.

When using the _forward method within the preDispatch method, an infinite loop is caused. Example code:


class ResourcesController extends Zend_Controller_Action {

    public function preDispatch () {
        if ($this->_request->action != 'index') {
            $this->_forward('index');
        }
    }
    
    public function indexAction () {
    
    }

}

This causes an infinite loop when attempting to access [baseUrl]/resources/[actionBesidesIndex].

If the forward arguments are extended in the following manner, however...


class ResourcesController extends Zend_Controller_Action {

    public function preDispatch () {
        if ($this->_request->action != 'index') {
            $this->_forward('index',null,null,array('action'=>'index'));
        }
    }
    
    public function indexAction () {
    
    }

}

...then the _forward works as expected.

This could use a very simple patch, unless for some not-readily-apparent reason this one line of code would cause some undesirable side-effects:



*** /mnt/www/projects-live/library/Zend/Controller/Action.php   2012-03-07 14:56:40.000000000 -0600
--- Action.php  2012-06-22 17:13:14.000000000 -0500
***************
*** 673,678 ****
--- 673,679 ----
          }

          $request->setActionName($action)
+                 ->setParam('action',$action)
                  ->setDispatched(false);
      }

Comments

No comments to display