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

Surely the entire code block of:


if (is_readable($filename)) {
    return true;
}

can be removed?

Yes, the block what i commented out.

I should read better!

This was fixed in svn (r25020) on 2012-07-06 and so was in 1.12.0.