[BUGFIX] Filemtime / Filesize trigger warning 41/25541/2
authorTomita Militaru <militarutomita@gmail.com>
Mon, 11 Nov 2013 19:53:22 +0000 (21:53 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Wed, 20 Nov 2013 18:54:02 +0000 (19:54 +0100)
Adds check for file_exists before calling filemtime / filsize
to avoid warning message.

Resolves: #53243
Releases: 6.2, 6.1, 6.0
Change-Id: I0f7da0c3e1920ddcf7d2d427a48ddcca71a6a4a3
Reviewed-on: https://review.typo3.org/25541
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/core/Classes/Resource/ResourceCompressor.php

index ee056fb..52d7f97 100644 (file)
@@ -305,7 +305,11 @@ class ResourceCompressor {
                                $filename = $filesToInclude[$key];
                        }
                        $filepath = GeneralUtility::resolveBackPath($this->rootPath . $filename);
-                       $unique .= $filename . filemtime($filepath) . filesize($filepath);
+                       if (@file_exists($filepath)) {
+                               $unique = $filepath . filemtime($filepath) . filesize($filepath);
+                       } else {
+                               $unique = $filepath;
+                       }
                }
                $targetFile = $this->targetDirectory . 'merged-' . md5($unique) . '.' . $type;
                // if the file doesn't already exist, we create it
@@ -365,7 +369,12 @@ class ResourceCompressor {
        public function compressCssFile($filename) {
                // generate the unique name of the file
                $filenameAbsolute = GeneralUtility::resolveBackPath($this->rootPath . $this->getFilenameFromMainDir($filename));
-               $unique = $filenameAbsolute . filemtime($filenameAbsolute) . filesize($filenameAbsolute);
+               if (@file_exists($filenameAbsolute)) {
+                       $unique = $filenameAbsolute . filemtime($filenameAbsolute) . filesize($filenameAbsolute);
+               } else {
+                       $unique = $filenameAbsolute;
+               }
+
                $pathinfo = PathUtility::pathinfo($filename);
                $targetFile = $this->targetDirectory . $pathinfo['filename'] . '-' . md5($unique) . '.css';
                // only create it, if it doesn't exist, yet
@@ -502,7 +511,11 @@ class ResourceCompressor {
        public function compressJsFile($filename) {
                // generate the unique name of the file
                $filenameAbsolute = GeneralUtility::resolveBackPath($this->rootPath . $this->getFilenameFromMainDir($filename));
-               $unique = $filenameAbsolute . filemtime($filenameAbsolute) . filesize($filenameAbsolute);
+               if (@file_exists($filenameAbsolute)) {
+                       $unique = $filenameAbsolute . filemtime($filenameAbsolute) . filesize($filenameAbsolute);
+               } else {
+                       $unique = $filenameAbsolute;
+               }
                $pathinfo = PathUtility::pathinfo($filename);
                $targetFile = $this->targetDirectory . $pathinfo['filename'] . '-' . md5($unique) . '.js';
                // only create it, if it doesn't exist, yet