[BUGFIX] t3lib_Compressor: Avoid reference in foreach loop
authorFrederic Gaus <gaus@flagbit.de>
Thu, 15 Sep 2011 13:57:29 +0000 (15:57 +0200)
committerHelmut Hummel <typo3@helmut-hummel.de>
Thu, 15 Sep 2011 19:07:37 +0000 (21:07 +0200)
This fixes a bug introduced in #29695. There is a PHP bug
when using $filename as a reference and later on as a variable in
a foreach loop. The problem is described here:

http://www.php.net/manual/de/control-structures.foreach.php#101425

PHP 5.3.2 (used in current Ubuntu) and 5.3.3 (used in current Debian)
are affected. Other versions could be affected, too.

Avoiding the use of reference in the foreach loop fixes the bug.

Change-Id: I74c0ceee40e170b7cf2e7db91b1554d811a7c844
Resolves: #29832
Releases: 4.6
Related: #29695
Reviewed-on: http://review.typo3.org/4983
Reviewed-by: Steffen Gebert
Tested-by: Steffen Gebert
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
t3lib/class.t3lib_compressor.php

index 79a77eb..76aa9a8 100644 (file)
@@ -286,9 +286,10 @@ class t3lib_Compressor {
                        // we add up the filenames, filemtimes and filsizes to later build a checksum over
                        // it and include it in the temporary file name
                $unique = '';
-               foreach ($filesToInclude as &$filename) {
+
+               foreach ($filesToInclude as $key => $filename) {
                        if (t3lib_div::isValidUrl($filename)) {
-                               $filename = $this->retrieveExternalFile($filename);
+                               $filesToInclude[$key] = $this->retrieveExternalFile($filename);
                        }
                        $filepath = t3lib_div::resolveBackPath($this->rootPath . $filename);
                        $unique .= $filename . filemtime($filepath) . filesize($filepath);