Issues

ZF-11708: Zend_Loader_Autoloader_Resource::autoload does include instead of include_once

Description

The autoload method returns include of a file. This results in duplicate inclusions when using a PHP 5.3 namespaced interface class. When I change the include to include_once, the problem is solved.

To autoload PHP namespaced model classes I use:


class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initAutoloader()
    {
        $loader = function($className) {
            $zfClassName = str_replace('\\', '_', $className);
            if (!class_exists($className, false) && !class_exists($zfClassName, false)) {
                Zend_Loader_Autoloader::autoload($zfClassName);
            }
        };

        $autoloader = Zend_Loader_Autoloader::getInstance();
                // Scrum is set as appnamespace = "Scrum" within application.ini
        $autoloader->pushAutoloader($loader, 'Scrum\\');
    }
}

Comments

Same problem here. Following code is critical:

public function autoload($class)
{
    $classPath = $this->getClassPath($class);
    if (false !== $classPath) {
        return include $classPath;
    }
    return false;
}

And still in trunk...

i'm getting, what i believe to be the same issue - after moving zend/doctrine to a new server i get a fatal 'cannot redeclare class' error after running 'class_exists' check on the class.

not sure what other details would be relevant