[BUFGIX] Remove all existing processed files on file replace 42/36542/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:04:22 +0000 (11:04 +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/36542
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Thomas Deuling <tdeuling@gmail.com>
Tested-by: Thomas Deuling <tdeuling@gmail.com>
Reviewed-by: Ruud Silvrants <ruudsilvrants@gmail.com>
Tested-by: Ruud Silvrants <ruudsilvrants@gmail.com>
Reviewed-by: Roman Schürmann <roman.schuermann@wmdb.de>
Reviewed-by: Jan Helke <typo3@helke.de>
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 8b88a19..0ccac03 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 bba4462..9872fd7 100644 (file)
@@ -2167,7 +2167,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 99d72c4..f533d57 100644 (file)
@@ -26,6 +26,20 @@ $signalSlotDispatcher->connect(
        'removeFromRepository'
 );
 
+$signalSlotDispatcher->connect(
+       \TYPO3\CMS\Core\Resource\ResourceStorage::class,
+       \TYPO3\CMS\Core\Resource\ResourceStorageInterface::SIGNAL_PostFileAdd,
+       \TYPO3\CMS\Core\Resource\Processing\FileDeletionAspect::class,
+       'cleanupProcessedFilesPostFileAdd'
+);
+
+$signalSlotDispatcher->connect(
+       \TYPO3\CMS\Core\Resource\ResourceStorage::class,
+       \TYPO3\CMS\Core\Resource\ResourceStorageInterface::SIGNAL_PostFileReplace,
+       \TYPO3\CMS\Core\Resource\Processing\FileDeletionAspect::class,
+       'cleanupProcessedFilesPostFileReplace'
+);
+
 unset($signalSlotDispatcher);
 
 $GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['dumpFile'] = 'EXT:core/Resources/PHP/FileDumpEID.php';