Explorar el Código

ZF-9100: ensure Zend_Loader::isReadable() returns accurate results against fully qualified paths

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20989 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew hace 16 años
padre
commit
9dce8894d3
Se han modificado 2 ficheros con 16 adiciones y 0 borrados
  1. 6 0
      library/Zend/Loader.php
  2. 10 0
      tests/Zend/LoaderTest.php

+ 6 - 0
library/Zend/Loader.php

@@ -173,6 +173,12 @@ class Zend_Loader
      */
     public static function isReadable($filename)
     {
+        if (is_readable($filename)) {
+            // Return early if the filename is readable without needing the 
+            // include_path
+            return true;
+        }
+
         foreach (self::explodeIncludePath() as $path) {
             if ($path == '.') {
                 if (is_readable($filename)) {

+ 10 - 0
tests/Zend/LoaderTest.php

@@ -526,6 +526,16 @@ class Zend_LoaderTest extends PHPUnit_Framework_TestCase
     }
 
     /**
+     * @group ZF-9100
+     */
+    public function testIsReadableShouldReturnTrueForAbsolutePaths()
+    {
+        set_include_path(dirname(__FILE__) . '../../');
+        $path = dirname(__FILE__);
+        $this->assertTrue(Zend_Loader::isReadable($path));
+    }
+
+    /**
      * In order to play nice with spl_autoload, an autoload callback should
      * *not* emit errors (exceptions are okay). ZF-2923 requests that this
      * behavior be applied, which counters the previous request in ZF-2463.