Zend Framework

Zend_Loader_Autoloader_Resource::autoload

Details

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

Description

This method will fail getting the right path because it is adding two slashes at the beginning of the name of the file.

In the method, where it reads (line 176):
return include $path . '/' . str_replace('_', '/', $final) . '.php';
it must be
return include $path . str_replace('_', '/', $final) . '.php';

also, I noticed that in the same method in the line 159 that it reads
$final = array_pop($segments);
but in the line 174
$final = substr($class, strlen($lastMatch));

this is overriding the previous line, so another possibly solution to this is
return include $path . '/' . $final . '.php';

Anyway, this is not a good practice in the code.

Cheers,
Rodrigo Cervone.

Issue Links

Activity

Hide
Jeroen Keppens added a comment -

Removing the slash there is not a good solution, that way you expect both other parts to have a slash.

I'd suggest a fix 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 - Removing the slash there is not a good solution, that way you expect both other parts to have a slash. I'd suggest a fix 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 -

fixed with ZF-6727

Show
Marco Kaiser added a comment - fixed with ZF-6727

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: