ZF-12322: Zend_Loader::isReadable sometime duplicates calls to is_readable

Issue Type: Improvement Created: 2012-07-05T12:00:22.000+0000 Last Updated: 2012-12-22T12:32:47.000+0000 Status: Closed Fix version(s): Reporter: Michiel Thalen (chielsen) Assignee: Rob Allen (rob) Tags: - Zend_Loader

Related issues: Attachments:


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:

<pre class="highlight">
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 == '.') {
                //if (is_readable($filename)) {
                //    return true;
            $file = $path . '/' . $filename;
            if (is_readable($file)) {
                return true;
        return false;


Posted by Rob Allen (rob) on 2012-07-06T10:45:27.000+0000

Surely the entire code block of:

<pre class="highlight">
if (is_readable($filename)) {
    return true;

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.

Have you found an issue?

See the Overview section for more details.


© 2006-2020 by Zend by Perforce. Made with by awesome contributors.

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