ZF-6727: Zend_Loader_Autoloader_Resource generated double slash in path name


in the autoload method the return statement look like

return include $path . '/' . str_replace('_', '/', $final) . '.php';

this results in a double // the . '/' after path is not required or maybe should be checked because its results in a path require like this



Set component and auto reassign

Confirmed for me. I get some "/media/www/anaskaformationZF/application/default/models/Acl///MyAcl.php" when trying new Acl_MyAcl with

$autoloader = new Zend_Loader_Autoloader_Resource(array(
 'basePath'      => $appPath . '/default/models',
 'namespace'     => '',
 'resourceTypes' => array('tables'=>array('path'=>'Tables/','namespace'=>'Table'),
                          'objects'=>array('path'=>'Objects/', 'namespace'=>'Object'),
                          'forms'=>array('path'=>'Forms/', 'namespace'=>'Form'),
                          'acl'=>array('path'=>'Acl/', 'namespace'=>'Acl')

Double slashes in path too.

For Windows its good, but for linux i have this error in path:


Looks like it is a counting error, changing ln 174 from:

    $final = substr($class, strlen($lastMatch));


    $final = substr($class, strlen($lastMatch)+1);

Fixes the issue.

Could be fixed by changing:

return include $path . '/' . str_replace('_', '/', $final) . '.php';


return rtrim(include $path, '/') . '/' . ltrim(str_replace('_', '/', $final), '/') . '.php';

That way you remove right trailing slashes from the path and left trailing slashes from the final bit.

Solution diff, please fix

correct patch

fixed in r19084

This patch breaks the autoloading of custom classes in my project. I get the error:

Warning: include() [function.include]: Filename cannot be empty in C:\appliaction\svn\trunk\library\Zend\Loader\Autoloader\Resource.php on line 188 Warning: include() [function.include]: Failed opening '' for inclusion (include_path='C:\application\svn\trunk\application/models/doctrine;C:\application\svn\trunk\library;.;C:\php5\pear') in C:\application\svn\trunk\library\Zend\Loader\Autoloader\Resource.php on line 188

And the class being passed to autoload() is "Custom_Acl"

Your autoload() class does not return false. It tried to include "false" as a file. Try:

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

Looks like we've stumbled across the same problemĀ ...I submitted a patch almost identical to what you're suggesting earlier this afternoon at . There are a few other issues that talk about the same thing too, so hopefully it'll make it in.

I fix the problem in ZF-8364.