Fixed issue #13670: Performance optimization: change while(list() to foreach() (thank...
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_basicfilefunc.php
index 94e51a9..f9e42c8 100644 (file)
@@ -67,7 +67,6 @@
  *
  */
 
-require_once(PATH_t3lib.'class.t3lib_cs.php');
 
 
 /**
@@ -325,8 +324,7 @@ class t3lib_basicFileFunctions      {
         */
        function checkPathAgainstMounts($thePath)       {
                if ($thePath && $this->isPathValid($thePath) && is_array($this->mounts))        {
-                       reset ($this->mounts);
-                       while(list($k,$val)=each($this->mounts))        {
+                       foreach ($this->mounts as $k => $val) {
                                if (t3lib_div::isFirstPartOfStr($thePath,$val['path'])) {
                                        return $k;
                                }
@@ -343,8 +341,7 @@ class t3lib_basicFileFunctions      {
                global $TYPO3_CONF_VARS;
 
                if (is_array($this->mounts))    {
-                       reset ($this->mounts);
-                       while(list($k,$val)=each($this->mounts))        {
+                       foreach ($this->mounts as $k => $val) {
                                if (t3lib_div::isFirstPartOfStr($val['path'], PATH_site.$TYPO3_CONF_VARS['BE']['fileadminDir']))        {
                                        return $k;
                                }
@@ -377,8 +374,7 @@ class t3lib_basicFileFunctions      {
         */
        function findTempFolder()       {
                if ($this->tempFN && is_array($this->mounts))   {
-                       reset ($this->mounts);
-                       while(list($k,$val)=each($this->mounts))        {
+                       foreach ($this->mounts as $k => $val) {
                                $tDir = $val['path'].$this->tempFN;
                                if (@is_dir($tDir))     {
                                        return $tDir;
@@ -455,11 +451,11 @@ class t3lib_basicFileFunctions    {
                                // Get conversion object or initialize if needed
                        if (!is_object($this->csConvObj)) {
                                if (TYPO3_MODE=='FE') {
-                                       $this->csConvObj = &$GLOBALS['TSFE']->csConvObj;
+                                       $this->csConvObj = $GLOBALS['TSFE']->csConvObj;
                                } elseif (is_object($GLOBALS['LANG'])) {        // BE assumed:
-                                       $this->csConvObj = &$GLOBALS['LANG']->csConvObj;
+                                       $this->csConvObj = $GLOBALS['LANG']->csConvObj;
                                } else {        // The object may not exist yet, so we need to create it now. Happens in the Install Tool for example.
-                                       $this->csConvObj = &t3lib_div::makeInstance('t3lib_cs');
+                                       $this->csConvObj = t3lib_div::makeInstance('t3lib_cs');
                                }
                        }
 
@@ -491,8 +487,11 @@ class t3lib_basicFileFunctions     {
         *
         * @param       integer         Bytes to be formated
         * @return      string          Formatted with M,K or    appended.
+        * @deprecated since at least TYPO3 4.2 - Use t3lib_div::formatSize() instead
         */
        function formatSize($sizeInBytes)       {
+               t3lib_div::logDeprecatedFunction();
+
                if ($sizeInBytes>900)   {
                        if ($sizeInBytes>900000)        {       // MB
                                $val = $sizeInBytes/(1024*1024);