Zend Framework

Zend_Application_Resource_Modules with setFallbackAutoloader turned on causes failure

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.8.1, 1.8.2
  • Fix Version/s: None
  • Labels:
    None

Description

If you have setFallbackAutoloader turned on:

$autoloader = Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);

Then the call to class_exists() in Zend_Application_Resource_Modules to load the {Module}_Bootstrap class will fail.

Here is the patch to correct the issue:

Index: Modules.php
===================================================================
--- Modules.php	(revision 15619)
+++ Modules.php	(working copy)
@@ -38,8 +38,8 @@
 
     /**
      * Constructor
-     * 
-     * @param  mixed $options 
+     *
+     * @param  mixed $options
      * @return void
      */
     public function __construct($options = null)
@@ -68,7 +68,7 @@
             }
 
             $bootstrapClass = $this->_formatModuleName($module) . '_Bootstrap';
-            if (!class_exists($bootstrapClass)) {
+            if (!class_exists($bootstrapClass, false)) {
                 $bootstrapPath  = $front->getModuleDirectory($module) . '/Bootstrap.php';
                 if (file_exists($bootstrapPath)) {
                     include_once $bootstrapPath;
@@ -90,7 +90,7 @@
 
     /**
      * Get bootstraps that have been run
-     * 
+     *
      * @return ArrayObject
      */
     public function getExecutedBootstraps()
@@ -100,8 +100,8 @@
 
     /**
      * Format a module name to the module class prefix
-     * 
-     * @param  string $name 
+     *
+     * @param  string $name
      * @return string
      */
     protected function _formatModuleName($name)

Activity

Hide
Chris Jones added a comment -

Updating title to be more descriptive

Show
Chris Jones added a comment - Updating title to be more descriptive
Hide
Miroslav Kubelik added a comment -

Yes, this is very annoing and it doesn't have any useful workaround, maybe enable fallback autoloader at the end of module_bootstrap,
I'm voting for it please. Patch seems very easy. It's still in 1.8.3.

Show
Miroslav Kubelik added a comment - Yes, this is very annoing and it doesn't have any useful workaround, maybe enable fallback autoloader at the end of module_bootstrap, I'm voting for it please. Patch seems very easy. It's still in 1.8.3.
Hide
Jurrien Stutterheim added a comment -

Fixed with solution for ZF-7002

Show
Jurrien Stutterheim added a comment - Fixed with solution for ZF-7002

People

Vote (2)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: