ZF-8523: Zend_Controller_Plugins_ErrorHandler uses layout script twice

Issue Type: Bug Created: 2009-12-11T09:04:13.000+0000 Last Updated: 2012-11-20T20:52:32.000+0000 Status: Closed Fix version(s): Reporter: boris (jer) Assignee: None Tags: - Zend_Controller

Related issues: Attachments:


This bug shows when you have 2+ actions in stack and first runs ok and any subsequent produces error:

<pre class="highlight">
class IndexController extends Zend_Controller_Action
    public function indexAction()
        $this->view->message = 'run ok';
        $this->_helper->actionStack('nonExistentAction', 'nonExistentController');


As far as I debugged this - layout plugin's postDispatch() wraps content twice with layout script, didn't look deeper to find why.

Of cause adding non-existent actions into stack is just for example. Actually I move user request to second action and my first action does some stuff that must precede any processing. And if request goes to non-existent controller - user sees such a 'beautiful' thing.

As workaround:

<pre class="highlight">
class ErrorController extends Zend_Controller_Action
    public function errorAction()

P.S. Bug is trivial - by default Zend_Layout_Controller_Plugin_Layout is registered at index 99, Zend_Controller_Plugin_ErrorHandler at index 100. In postDispatch() layout plugin finds that request is dispatched and runs its actions, then error handler's postDispatch() adds another request and layout plugin finds another dispathed request and runs again. Changing register order solves the problem.


Posted by Matthew Weier O'Phinney (matthew) on 2009-12-11T09:27:49.000+0000

Assigning to Ralph

Posted by Rob Allen (rob) on 2012-11-20T20:52:32.000+0000

Bulk change of all issues last updated before 1st January 2010 as "Won't Fix".

Feel free to re-open and provide a patch if you want to fix this issue.

Have you found an issue?

See the Overview section for more details.


© 2006-2020 by Zend by Perforce. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.