Browse Source

ZF-9506: error on list files if a directory can't list or glob returns false on empty directories

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@21636 44c647ce-9c0f-0410-b52a-842ac1e357ba
mabe 16 years ago
parent
commit
a073c43803
1 changed files with 9 additions and 2 deletions
  1. 9 2
      library/Zend/Cache/Backend/File.php

+ 9 - 2
library/Zend/Cache/Backend/File.php

@@ -647,6 +647,7 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
         $prefix = $this->_options['file_name_prefix'];
         $glob = @glob($dir . $prefix . '--*');
         if ($glob === false) {
+            // On some systems it is impossible to distinguish between empty match and an error.
             return true;
         }
         foreach ($glob as $file)  {
@@ -739,7 +740,8 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
         $prefix = $this->_options['file_name_prefix'];
         $glob = @glob($dir . $prefix . '--*');
         if ($glob === false) {
-            return true;
+            // On some systems it is impossible to distinguish between empty match and an error.
+            return array();
         }
         foreach ($glob as $file)  {
             if (is_file($file)) {
@@ -802,7 +804,12 @@ class Zend_Cache_Backend_File extends Zend_Cache_Backend implements Zend_Cache_B
             }
             if ((is_dir($file)) and ($this->_options['hashed_directory_level']>0)) {
                 // Recursive call
-                $result = array_unique(array_merge($result, $this->_get($file . DIRECTORY_SEPARATOR, $mode, $tags)));
+                $recursiveRs =  $this->_get($file . DIRECTORY_SEPARATOR, $mode, $tags);
+                if ($recursiveRs === false) {
+                    $this->_log('Zend_Cache_Backend_File::_get() / recursive call : can\'t list entries of "'.$file.'"');
+                } else {
+                    $result = array_unique(array_merge($result, $recursiveRs));
+                }
             }
         }
         return array_unique($result);