Fixed bug #12128: Performance improvement in t3lib_div::get_dirs() (thanks to Dan...
authorRupert Germann <rupi@gmx.li>
Thu, 8 Oct 2009 20:21:48 +0000 (20:21 +0000)
committerRupert Germann <rupi@gmx.li>
Thu, 8 Oct 2009 20:21:48 +0000 (20:21 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@6114 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_div.php

index 29db48b..5076733 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2009-10-08  Rupert Germann  <rupi@gmx.li>
 
        * Fixed bug #12121: "Installation Type: L" - tell the user, what's "L" (thanks to Steffen Gebert)
+       * Fixed bug #12128: Performance improvement in t3lib_div::get_dirs() (thanks to Dan Osipov)
 
 2009-10-08  Oliver Hader  <oliver@typo3.org>
 
index 693961b..a61cea8 100644 (file)
@@ -3090,18 +3090,20 @@ final class t3lib_div {
         * @return      array           Returns an array with the directory entries as values. If no path, the return value is nothing.
         */
        public static function get_dirs($path)  {
-               if ($path)      {
-                       $d = @dir($path);
-                       if (is_object($d))      {
-                               while(false !== ($entry=$d->read())) {
-                                       if (@is_dir($path.'/'.$entry) && $entry!= '..' && $entry!= '.') {
-                                               $filearray[]=$entry;
+               if ($path) {
+                       if (is_dir($path)) {
+                               $dir = scandir($path);
+                               $dirs = array();
+                               foreach ($dir as $entry) {
+                                       if (is_dir($path . '/' . $entry) && $entry != '..' && $entry != '.') {
+                                               $dirs[] = $entry;
                                        }
                                }
-                               $d->close();
-                       } else return 'error';
-                       return $filearray;
+                       } else {
+                               $dirs = 'error';
+                       }
                }
+               return $dirs;
        }
 
        /**