ZF-12322: Zend_Loader::isReadable sometime duplicates calls to is_readable
Description
There is an early call to is_readable($filename), but later on this call is executed again (sometimes). We should remove the duplicate call in the foreach.
New version:
public static function isReadable($filename)
{
if (is_readable($filename)) {
// Return early if the filename is readable without needing the
// include_path
return true;
}
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'
&& preg_match('/^[a-z]:/i', $filename)
) {
// If on windows, and path provided is clearly an absolute path,
// return false immediately
return false;
}
foreach (self::explodeIncludePath() as $path) {
if ($path == '.') {
/** THIS SHOULD BE REMOVED **/
//if (is_readable($filename)) {
// return true;
//}
continue;
}
$file = $path . '/' . $filename;
if (is_readable($file)) {
return true;
}
}
return false;
}
Comments
Posted by Rob Allen (rob) on 2012-07-06T10:45:27.000+0000
Surely the entire code block of:
can be removed?
Posted by Michiel Thalen (chielsen) on 2012-07-06T10:57:58.000+0000
Yes, the block what i commented out.
Posted by Rob Allen (rob) on 2012-07-06T10:59:33.000+0000
I should read better!
Posted by Rob Allen (rob) on 2012-12-22T12:32:47.000+0000
This was fixed in svn (r25020) on 2012-07-06 and so was in 1.12.0.