Zend Framework

Zend_Loader_Autoloader_Resource generated double slash in path name

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.8.1
  • Fix Version/s: 1.10.0
  • Component/s: Zend_Loader
  • Labels:
    None

Description

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

application/modules/i18n/models//Example.php

Issue Links

Activity

Hide
Satoru Yoshida added a comment -

Set component and auto reassign

Show
Satoru Yoshida added a comment - Set component and auto reassign
Hide
julien PAULI added a comment -

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')
)));
Show
julien PAULI added a comment - 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')
)));
Hide
Andrey Kulikov added a comment -

Double slashes in path too.

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

Warning: Zend_Loader_Autoloader_Resource::include() [function.include]: Failed opening '/var/www/vhosts/artgroup.by/subdomains/job67/httpdocs/application/modules/job/models//Company/RegisterForm.php' for inclusion (include_path='/var/www/vhosts/artgroup.by/subdomains/job67/httpdocs/library:/var/www/vhosts/artgroup.by/subdomains/job67/httpdocs/libs:/var/www/vhosts/artgroup.by/subdomains/job67/../../libs:.:') in /var/www/vhosts/artgroup.by/subdomains/job67/httpdocs/libs/Zend/Loader/Autoloader/Resource.php on line 173
Show
Andrey Kulikov added a comment - Double slashes in path too. For Windows its good, but for linux i have this error in path:
Warning: Zend_Loader_Autoloader_Resource::include() [function.include]: Failed opening '/var/www/vhosts/artgroup.by/subdomains/job67/httpdocs/application/modules/job/models//Company/RegisterForm.php' for inclusion (include_path='/var/www/vhosts/artgroup.by/subdomains/job67/httpdocs/library:/var/www/vhosts/artgroup.by/subdomains/job67/httpdocs/libs:/var/www/vhosts/artgroup.by/subdomains/job67/../../libs:.:') in /var/www/vhosts/artgroup.by/subdomains/job67/httpdocs/libs/Zend/Loader/Autoloader/Resource.php on line 173
Hide
Jake McGraw added a comment -

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

Unable to find source-code formatter for language: php. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java

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

{/code}

to:

Unable to find source-code formatter for language: php. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java


$final = substr($class, strlen($lastMatch)+1);{/code}

Fixes the issue.

Show
Jake McGraw added a comment - Looks like it is a counting error, changing ln 174 from:
Unable to find source-code formatter for language: php. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java

$final = substr($class, strlen($lastMatch)); {/code} to:
Unable to find source-code formatter for language: php. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java

$final = substr($class, strlen($lastMatch)+1);{/code} Fixes the issue.
Hide
Jeroen Keppens added a comment -

Could be fixed by changing:

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

to:

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.

Show
Jeroen Keppens added a comment - Could be fixed by changing: return include $path . '/' . str_replace('_', '/', $final) . '.php'; to: 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.
Hide
Marco Kaiser added a comment -

Solution diff, please fix

Show
Marco Kaiser added a comment - Solution diff, please fix
Hide
Marco Kaiser added a comment -

correct patch

Show
Marco Kaiser added a comment - correct patch
Hide
Marco Kaiser added a comment -

fixed in r19084

Show
Marco Kaiser added a comment - fixed in r19084
Hide
Marc Peterson added a comment -

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; }
Show
Marc Peterson added a comment - 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; }
Hide
Adam Jensen added a comment -

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

Show
Adam Jensen added a comment - Looks like we've stumbled across the same problemĀ ...I submitted a patch almost identical to what you're suggesting earlier this afternoon at http://framework.zend.com/issues/browse/ZF-8364 . There are a few other issues that talk about the same thing too, so hopefully it'll make it in.
Hide
Marco Kaiser added a comment -

I fix the problem in ZF-8364.

Show
Marco Kaiser added a comment - I fix the problem in ZF-8364.

People

Vote (5)
Watch (9)

Dates

  • Created:
    Updated:
    Resolved: