Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 1.10.4, 1.10.5, 1.10.6
-
Fix Version/s: 1.11.6
-
Component/s: Zend_Loader
-
Labels:None
Description
Wrong arrays union in Zend_Loader_Autoloader::getClassAutoloaders, if $autoloaders isn't empty array.
See last comment at http://www.php.net/manual/en/language.operators.array.php#86379
Example:
<?php
include "Zend/Loader/Autoloader.php";
$zend_loader = Zend_Loader_Autoloader::getInstance();
class Loader implements Zend_Loader_Autoloader_Interface
{
public function autoload($class)
{
/* do something */
}
}
$zend_loader->
registerNamespace('Test')->
pushAutoloader(new Loader());
var_dump(count($zend_loader->getClassAutoloaders('Test_Class')));
Output (only Zend_Loader_Autoloader instance):
int(1)
Must be (Zend_Loader_Autoloader and Loader instances):
int(2)
Patch for fix:
--- Autoloader.php 2010-07-12 14:13:33.000000000 +0700
+++ Autoloader.new.php 2010-07-12 14:14:12.000000000 +0700
@@ -338,7 +338,7 @@
}
if (0 === strpos($class, $ns)) {
$namespace = $ns;
- $autoloaders = $autoloaders + $this->getNamespaceAutoloaders($ns);
+ $autoloaders = array_merge($autoloaders, $this->getNamespaceAutoloaders($ns));
break;
}
}
@@ -353,7 +353,7 @@
}
// Add non-namespaced autoloaders
- $autoloaders = $autoloaders + $this->getNamespaceAutoloaders('');
+ $autoloaders = array_merge($autoloaders, $this->getNamespaceAutoloaders(''));
// Add fallback autoloader
if (!$namespace && $this->isFallbackAutoloader()) {
Attachments
Issue Links
| This issue is related to: | ||||
| ZF-10779 | Autoloaders lost in Zend_Loader_Autoloader |
|
|
|
This issue still exists in ZF 1.10.8 and even on trunk today.
Maintainers, please commit this patch.