ZF-11867: Module resource bootstraps default module when it's not supposed to


When I run my application using a cli.ini config file, which specifies the bootstrap options as:

bootstrap.path = APPLICATION_PATH "/CliBootstrap.php" bootstrap.class = "CliBootstrap"

Zend_Application_Resource_Modules#init() sets $bootstrapClass to "Bootstrap" (hard-coded) instead of getting this information from the config (or using $curBootstrapClass).

This results in the default module's Bootstrap being executed, when this has already been taken care of by the CliBootstrap.

One fix would be the following:

    //$bootstrapClass = 'Bootstrap';
    $bootstrapOptions = $this->getBootstrap()->getApplication()->getOption('bootstrap');
    $bootstrapClass = $bootstrapOptions['class']; // Or $curBootstrapClass.

Although the code in this method could probably be simplified. You could probably "continue:" if $module === $default.


Simple test project.

Run it using: php cli.php (from the scripts directory)

Expected output:

CLI Bootstrap Admin Bootstrap Blog Bootstrap

Actual output:

CLI Bootstrap App Bootstrap Admin Bootstrap Blog Bootstrap Admin Bootstrap Blog Bootstrap

... so not only is it bootstrapping the "App" bootstrap, it also appears to be bootstrapping modules twice (unless I messed something up when trying to keep the project as small as possible).