[BUFGIX] Remove all existing processed files on file replace 97/36597/3
authorruud <ruudsilvrants@gmail.com>
Sat, 31 Jan 2015 16:59:10 +0000 (17:59 +0100)
committerFrans Saris <franssaris@gmail.com>
Mon, 2 Feb 2015 10:49:01 +0000 (11:49 +0100)
When a file gets replaced by calling replaceFile() or by overriding
on uploading all processed files of the original file get removed.

Resolves: #63976
Releases: master, 6.2
Change-Id: I865503e46ac9044b22f976e0db5b163ac7e2e4c9
Reviewed-on: http://review.typo3.org/36597
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
typo3/sysext/core/Classes/Resource/Processing/FileDeletionAspect.php
typo3/sysext/core/Classes/Resource/ResourceStorage.php
typo3/sysext/core/ext_localconf.php

index 530e999..656fad7 100644 (file)
@@ -92,6 +92,26 @@ class FileDeletionAspect {
        }
 
        /**
+        * Remove all processed files on SIGNAL_PostFileAdd
+        *
+        * @param FileInterface $file
+        * @param string $targetFolder
+        */
+       public function cleanupProcessedFilesPostFileAdd(FileInterface $file, $targetFolder) {
+               $this->cleanupProcessedFiles($file);
+       }
+
+       /**
+        * Remove all processed files on SIGNAL_PostFileReplace
+        *
+        * @param FileInterface $file
+        * @param string $localFilePath
+        */
+       public function cleanupProcessedFilesPostFileReplace(FileInterface $file, $localFilePath) {
+               $this->cleanupProcessedFiles($file);
+       }
+
+       /**
         * Remove all category references of the deleted file.
         *
         * @param File $fileObject
index 86b9ca9..87e885a 100644 (file)
@@ -2247,7 +2247,7 @@ class ResourceStorage implements ResourceStorageInterface {
         * Emits the file post-replace signal
         *
         * @param FileInterface $file
-        * @param $localFilePath
+        * @param string $localFilePath
         * @return void
         */
        protected function emitPostFileReplaceSignal(FileInterface $file, $localFilePath) {
index 828d6b8..9564944 100644 (file)
@@ -27,6 +27,20 @@ $signalSlotDispatcher->connect(
        'removeFromRepository'
 );
 
+$signalSlotDispatcher->connect(
+       'TYPO3\\CMS\\Core\\Resource\\ResourceStorage',
+       \TYPO3\CMS\Core\Resource\ResourceStorageInterface::SIGNAL_PostFileAdd,
+       'TYPO3\\CMS\\Core\\Resource\\Processing\\FileDeletionAspect',
+       'cleanupProcessedFilesPostFileAdd'
+);
+
+$signalSlotDispatcher->connect(
+       'TYPO3\\CMS\\Core\\Resource\\ResourceStorage',
+       \TYPO3\CMS\Core\Resource\ResourceStorageInterface::SIGNAL_PostFileReplace,
+       'TYPO3\\CMS\\Core\\Resource\\Processing\\FileDeletionAspect',
+       'cleanupProcessedFilesPostFileReplace'
+);
+
 unset($signalSlotDispatcher);
 
 $GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['dumpFile'] = 'EXT:core/Resources/PHP/FileDumpEID.php';