ZF-7900: Each module bootstrap creates new instance of Zend_Application_Resource_Frontcontroller to bootstrap a FrontController

Issue Type: Bug Created: 2009-09-19T09:34:50.000+0000 Last Updated: 2012-11-20T21:37:37.000+0000 Status: Open Fix version(s): Reporter: Skryabin Ivan (dr.scre) Assignee: None Tags: - Zend_Application

Related issues: Attachments:


In Zend_Application_Module_Bootstrap __constructor() the lines below

    // ZF-6545: ensure front controller resource is loaded
    if (!$this->hasPluginResource('FrontController')) {

ensure, that front controller plugin resource is loaded. But this causes each module to bootstrap the FrontController anew, so an instance of Zend_Application_Resource_Frontcontroller is created for each module bootstrap.

I think that module bootstrap must have access to application bootstrap resources in some way (delegation?) to be able to track dependencies on global resources and prevent such duplications.


Posted by David Abdemoulaie (hobodave) on 2010-04-02T09:23:54.000+0000

This behavior seems questionable. I created a patch that allows the Frontcontroller resource to be reused by each module bootstrap.

This doesn't break any unit tests. However, the init() method of the Frontcontroller resource is still called 1 time per module bootstrap. This has a bizarre side effect when using resources.frontcontroller in your application.(ini|xml|php) -- each plugin is registered multiple times with the Zend_Controller_Front instance (other things are duplicated as well), and thus executed multiple times per request. However, if you don't use resources.frontcontroller, and instead use an _initFrontController() method in your bootstrap, this does not occur.

I tried forcing Frontcontroller::init() to run only once using a static variable, but this did break unit tests. I'm unsure why, and decided to take a break at this point.

Matthew do you have any insight?

Do you need a new instance of the Frontcontroller resource for every module? If not, does Frontcontroller::init() need to be called for every module? If not, why do tests break if I force it once?

Fun. :)

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

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