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
Posted by Martin S. (zickedi) on 2012-01-03T17:23:50.000+0000
Same problem here. Following code is critical:
And still in trunk...
Posted by jeff sank (jsank) on 2012-04-19T20:36:19.000+0000
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