[BUGFIX] compressJs returns wrong filenames 10/21410/2
authorPhilipp Gampe <philipp.gampe@typo3.org>
Thu, 16 May 2013 18:23:00 +0000 (20:23 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 29 Jun 2013 10:57:29 +0000 (12:57 +0200)
If you enable
    config.concatenateJs = 1
    config.compressJs = 1
then the uncompressed version of the file is linked.

This does not change much, because compression is disabled and the files
will always be uncompressed, however the right link should be generated.

The allows extension to override the compress method and implement
compression without fixing the rest of the code.

The bug is a regression introduced with: #27694 (4.6).

Return the correct filename by overriding the filename with the returned
value of compressJsFile.

Resolves: #48213
Related: #27694
Releases: 6.2, 6.1, 6.0, 4.7
Change-Id: I1f65576db8084b54f9e5a13947ced258eef893d7
Reviewed-on: https://review.typo3.org/20845
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
Reviewed-on: https://review.typo3.org/21410

typo3/sysext/core/Classes/Resource/ResourceCompressor.php

index e059c23..64a0436 100644 (file)
@@ -479,12 +479,15 @@ class ResourceCompressor {
         */
        public function compressJsFiles(array $jsFiles) {
                $filesAfterCompression = array();
-               foreach ($jsFiles as $key => $fileOptions) {
-                       // if compression is enabled
+               foreach ($jsFiles as $fileName => $fileOptions) {
+                       // If compression is enabled
                        if ($fileOptions['compress']) {
-                               $fileOptions['file'] = $this->compressJsFile($fileOptions['file']);
+                               $compressedFilename = $this->compressJsFile($fileOptions['file']);
+                               $fileOptions['file'] = $compressedFilename;
+                               $filesAfterCompression[$compressedFilename] = $fileOptions;
+                       } else {
+                               $filesAfterCompression[$fileName] = $fileOptions;
                        }
-                       $filesAfterCompression[$key] = $fileOptions;
                }
                return $filesAfterCompression;
        }
@@ -696,4 +699,4 @@ class ResourceCompressor {
 }
 
 
-?>
\ No newline at end of file
+?>