[BUGFIX] Do not reprocess image preview when empty configuration is passed 04/54804/3
authorTymoteusz Motylewski <t.motylewski@gmail.com>
Mon, 27 Nov 2017 21:09:52 +0000 (22:09 +0100)
committerFrans Saris <franssaris@gmail.com>
Tue, 12 Dec 2017 08:17:53 +0000 (09:17 +0100)
Fixes regression introduced in https://review.typo3.org/53399
Where thumbnail was regenerated every time process was called with
empty configuration like:

$fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, [])

Resolves: #83242
Relates: #81776
Releases: master, 8.7, 7.6
Change-Id: I6a4c331bad4d80225d3914f1a48f6071b0d87380
Reviewed-on: https://review.typo3.org/54804
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
typo3/sysext/core/Classes/Resource/File.php
typo3/sysext/core/Classes/Resource/ProcessedFile.php

index 3e9316d..b03f600 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Resource;
  */
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\MathUtility;
 
 /**
  * File representation in the file abstraction layer.
@@ -296,6 +297,11 @@ class File extends AbstractFile
      */
     public function process($taskType, array $configuration)
     {
+        if ($taskType === ProcessedFile::CONTEXT_IMAGEPREVIEW) {
+            $configuration = array_merge(['width' => 64, 'height' => 64], $configuration);
+            $configuration['width'] = MathUtility::forceIntegerInRange($configuration['width'], 1, 1000);
+            $configuration['height'] = MathUtility::forceIntegerInRange($configuration['height'], 1, 1000);
+        }
         return $this->getStorage()->processFile($this, $taskType, $configuration);
     }
 
index 1e4cc90..b97fd11 100644 (file)
@@ -118,11 +118,6 @@ class ProcessedFile extends AbstractFile
         $this->originalFileSha1 = $this->originalFile->getSha1();
         $this->storage = $originalFile->getStorage()->getProcessingFolder()->getStorage();
         $this->taskType = $taskType;
-        if ($taskType === self::CONTEXT_IMAGEPREVIEW) {
-            $processingConfiguration = array_merge(['width' => 64, 'height' => 64], $processingConfiguration);
-            $processingConfiguration['width'] = MathUtility::forceIntegerInRange($processingConfiguration['width'], 1, 1000);
-            $processingConfiguration['height'] = MathUtility::forceIntegerInRange($processingConfiguration['height'], 1, 1000);
-        }
         $this->processingConfiguration = $processingConfiguration;
         if (is_array($databaseRow)) {
             $this->reconstituteFromDatabaseRecord($databaseRow);