[BUGFIX] Only persist processedFile if processing was successful 26/39826/2
authorFrans Saris <franssaris@gmail.com>
Mon, 25 May 2015 07:19:24 +0000 (09:19 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Sat, 30 May 2015 22:26:08 +0000 (00:26 +0200)
Due to multiple reasons (for instance target folder is not writable)
the processing of a file can fail.

This change prevents wrong data being saved in sys_file_processedfile
when processing failed.

Resolves: #67094
Releases: master, 6.2
Change-Id: I6051d503ba74629dc6493b7bac9f28bf320aeb66
Reviewed-on: http://review.typo3.org/39826
Reviewed-by: Frank Nägler <typo3@naegler.net>
Tested-by: Frank Nägler <typo3@naegler.net>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/core/Classes/Resource/ProcessedFile.php
typo3/sysext/core/Classes/Resource/Processing/LocalImageProcessor.php
typo3/sysext/core/Classes/Resource/Service/FileProcessingService.php

index 38d342a..6e0f765 100644 (file)
@@ -257,7 +257,7 @@ class ProcessedFile extends AbstractFile {
         * @return boolean
         */
        public function isProcessed() {
-               return ($this->isPersisted() && !$this->needsReprocessing()) || $this->updated;
+               return $this->updated || ($this->isPersisted() && !$this->needsReprocessing());
        }
 
        /**
index 99214da..ac0e046 100644 (file)
@@ -63,7 +63,7 @@ class LocalImageProcessor implements ProcessorInterface {
                        if ($result === NULL) {
                                $task->setExecuted(TRUE);
                                $task->getTargetFile()->setUsesOriginalFile();
-                       } elseif (file_exists($result['filePath'])) {
+                       } elseif (!empty($result['filePath']) && file_exists($result['filePath'])) {
                                $task->setExecuted(TRUE);
                                $imageDimensions = $this->getGraphicalFunctionsObject()->getImageDimensions($result['filePath']);
                                $task->getTargetFile()->setName($task->getTargetFileName());
index 3c4a7be..db7300b 100644 (file)
@@ -115,7 +115,7 @@ class FileProcessingService {
                        $processor = Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Resource\Processing\LocalImageProcessor');
                        $processor->processTask($task);
 
-                       if ($processedFile->isProcessed()) {
+                       if ($task->isExecuted() && $task->isSuccessful() && $processedFile->isProcessed()) {
                                /** @var $processedFileRepository Resource\ProcessedFileRepository */
                                $processedFileRepository = Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\ProcessedFileRepository');
                                $processedFileRepository->add($processedFile);