Reputation: 9040
I noticed that my plugins are getting called twice. I know this for a fact because in my ViewSetup plugin it registers the headtitle, and the title contains the same content twice. Any ideas?
Upvotes: 2
Views: 1373
Reputation: 9040
This was due to an exception being thrown, which called subsequently the errorcontroller after the initial request.
Upvotes: 1
Reputation: 3128
Dump a debug_backtrace()
into a file and you can see where each call is coming from.
Upvotes: 0
Reputation: 2256
Your most likely duplicating the calls to preDispatch
or postDispatch
. These methods are called within a loop of the Zend_Controller_Front::dispatch
for every request that is not already dispatched. That means a cloned request with dispatch set to false and even using $this->_forward
in a controller will cause another execution of these methods.
Try changing to routeStartup
or routeShutdown
. Those will normally only run once for the application. If you absolutely need to run pre/postDispatch
, you should keep track in your plugin either with a count or by keeping a copy of the original request and checking if it's already in your plugin.
The other possibility is that your adding the plugin twice. This is likely if you are adding via the application.ini and also have registerPlugin
in your Bootstrap or other script. If your adding the plugin twice by accident, keeping a count of how many times you run the pre/postDispatch
will not help.
Upvotes: 4