[BUGFIX] Use FAL api to delete file in garbage collection task 32/50432/2
authorNicole Cordes <typo3@cordes.co>
Sat, 29 Oct 2016 12:47:08 +0000 (14:47 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 31 Oct 2016 15:40:27 +0000 (16:40 +0100)
This patch uses FAL file objects and their api to delete them from
recycler. This is needed to clean up the database entries as well.

Resolves: #78473
Releases: 7.6
Change-Id: Id0df73c19a5fed31bc074efccd9631ab8fffbfa8
Reviewed-on: https://review.typo3.org/50432
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/scheduler/Classes/Task/RecyclerGarbageCollectionTask.php

index dacaaae..9c5258c 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Scheduler\Task;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Resource\ResourceFactory;
+
 /**
  * Recycler folder garbage collection task
  *
@@ -65,7 +67,7 @@ class RecyclerGarbageCollectionTask extends \TYPO3\CMS\Scheduler\Task\AbstractTa
      * Gets a list of all files in a directory recursively and removes
      * old ones.
      *
-     * @throws \RuntimeException If folders are not found or files can not be deleted
+     * @throws \RuntimeException If folders are not found
      * @param string $directory Path to the directory
      * @param int $timestamp Timestamp of the last file modification
      * @return bool TRUE if success
@@ -88,9 +90,8 @@ class RecyclerGarbageCollectionTask extends \TYPO3\CMS\Scheduler\Task\AbstractTa
             }
             // Remove files from _recycler_ that where moved to this folder for more than 'number of days'
             if ($file->isFile() && $timestamp > $file->getCTime()) {
-                if (!@unlink($fileName)) {
-                    throw new \RuntimeException('Could not remove file "' . $fileName . '"', 1301614537);
-                }
+                $fileObject = ResourceFactory::getInstance()->getFileObjectFromCombinedIdentifier($filePath);
+                $fileObject->delete();
             }
         }
         return true;