ZF-5617: Static prefix and loaded plugins do not work in Zend_Loader_PluginLoader

Description

When using Zend_Loader_PluginLoader with a 'staticRegistryName' the static stuff will not work. The manual states that when using the staticRegistryName, another instance can use the already loaded plugins with the same registryname.

So:


$loader1 = new Zend_Loader_PluginLoader(array('Prefix_One', 'Prefix/One/'), 'STATICREGISTRYNAME');
$loader1->load('Bla');

echo $loader1->isLoaded('Bla'); // true

$loader2 = new Zend_Loader_PluginLoader(array(), 'STATICREGISTRYNAME');
$loader2->isLoaded('Bla'); // should be true according to manual....

But when I look in the constructor of Zend_Loader_PluginLoader I see that $_staticPrefixToPaths and $_staticLoadedPlugins for this registryname are cleared so that there are no loaded plugins at all (for that registryname).


    public function __construct(Array $prefixToPaths = array(), $staticRegistryName = null)
    {
        if (is_string($staticRegistryName) && !empty($staticRegistryName)) {
            $this->_useStaticRegistry = $staticRegistryName;
            self::$_staticPrefixToPaths[$staticRegistryName] = array(); // ---> with this the static functionality is gone.
            self::$_staticLoadedPlugins[$staticRegistryName] = array(); // ---> with this the static functionality is gone.
        }

        foreach ($prefixToPaths as $prefix => $path) {
            $this->addPrefixPath($prefix, $path);
        }
    }

I think that the wrong variables are cleared. It should not clear the static vars, but the 'normal' ones.


    public function __construct(Array $prefixToPaths = array(), $staticRegistryName = null)
    {
        if (is_string($staticRegistryName) && !empty($staticRegistryName)) {
            $this->_useStaticRegistry = $staticRegistryName;
            $this->_prefixToPaths[$staticRegistryName] = array();
            $this->_loadedPlugins[$staticRegistryName] = array();
        }

        foreach ($prefixToPaths as $prefix => $path) {
            $this->addPrefixPath($prefix, $path);
        }
    }

Comments

This issue is a duplicate of ZF-5208, which was fixed in 1.7.3

I'm sorry, missed that one! I thought i was already using 1.7.3 but it was 1.7.2.