ZF-6727: Zend_Loader_Autoloader_Resource generated double slash in path name

Issue Type: Bug Created: 2009-05-19T07:45:26.000+0000 Last Updated: 2009-11-25T00:28:54.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)

Reporter: Marco Kaiser (bate) Assignee: Marco Kaiser (bate) Tags: - Zend_Loader

Related issues: - ZF-8109

Attachments: - ZF-6727.diff


in the autoload method the return statement look like

<pre class="highlight">
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



Posted by old of Satoru Yoshida ( on 2009-05-22T21:28:06.000+0000

Set component and auto reassign

Posted by julien PAULI (doctorrock83) on 2009-06-12T02:54:50.000+0000

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

<pre class="highlight">
$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')

Posted by Andrey Kulikov (andkul) on 2009-09-11T05:42:50.000+0000

Double slashes in path too.

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



Posted by Jake McGraw (jakemcgraw) on 2009-09-29T13:21:31.000+0000

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

    <pre class="highlight">
        $final = substr($class, strlen($lastMatch));


    <pre class="highlight">
        $final = substr($class, strlen($lastMatch)+1);

Fixes the issue.



Posted by Jeroen Keppens (amazium) on 2009-11-19T00:52:08.000+0000

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.



Posted by Marco Kaiser (bate) on 2009-11-19T01:47:59.000+0000

Solution diff, please fix



Posted by Marco Kaiser (bate) on 2009-11-19T06:41:08.000+0000

correct patch



Posted by Marco Kaiser (bate) on 2009-11-20T05:11:53.000+0000

fixed in r19084



Posted by Marc Peterson (marcpeterson) on 2009-11-20T15:40:17.000+0000

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; }



Posted by Adam Jensen (jazzslider) on 2009-11-20T17:57:27.000+0000

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.



Posted by Marco Kaiser (bate) on 2009-11-22T23:48:07.000+0000

I fix the problem in ZF-8364.



Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.