Issues

ZF-8424: Zend_Application_Bootstrap_BootstrapAbstract::hasResourcePlugin() causes warnings.

Description

Zend_Application_Bootstrap_BootstrapAbstract::hasResourcePlugin() causes warnings.

See the next code:


require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance()
    ->suppressNotFoundWarnings(false)
    ->setFallbackAutoloader(true);
$bootstrap = new Zend_Application_Bootstrap_Bootstrap(new Zend_Application('test'));
if ($bootstrap->hasPluginResource('foo')) {   // causes warnings.
}

This warning caused by Zend_Application_Bootstrap_BootstrapAbstract::getPluginResource($resource) method. See the next code:


    public function getPluginResource($resource)
    {
        //...
            if (class_exists($plugin)) {    // <-- here. May be need to be class_exists($plugin, false);
                $spec = (array) $spec;
                $spec['bootstrap'] = $this;
                $instance = new $plugin($spec);
                $pluginName = $this->_resolvePluginResourceName($instance);
                unset($this->_pluginResources[$plugin]);
                $this->_pluginResources[$pluginName] = $instance;

                if (0 === strcasecmp($resource, $pluginName)) {
                    return $instance;
                }
            }
        //...
    }

Comments

fixed with r19310

The fix as applied needs to be backed out.

If we pass a boolean false to the second argument of class_exists(), then autoloading is bypassed -- which can be problematic if the developer intended for an autoloader to discover it.

Marco -- please revert your changes, and let me know once you have; I'll look into this issue.

reverted

On rev 19313 bate introduced a syntax error:

  • if (class_exists($plugin, false)) {
  • if (class_exists($plugin) {

The if statement is missing the closing parenthesis!

@Daniel Berstein: see ZF-8427 (resolved with r19314)

Closing as duplicate of ZF-7550. Please mind that fixing this one is a catch-22.