[BUGFIX] deleteRecord_flexFormCallBack deletes file_references 39/16239/11
authorLorenz Ulrich <lorenz.ulrich@visol.ch>
Tue, 6 Nov 2012 15:22:46 +0000 (16:22 +0100)
committerBenjamin Mack <benni@typo3.org>
Wed, 31 Dec 2014 10:47:12 +0000 (11:47 +0100)
Files that are referenced in a flexform
will be deleted by deleteRecord_flexFormCallBack() in
t3lib_TCEmain, independent of the path or usage by other records.

For normal record fields (e.g. tt_content.images), only file
with the internal_type "file" are deleted. Files of
internal_type "file_reference" are respected and will not be
deleted. There is an appropriate condition in

But for flexform fields, this differentiation in handling
between both internal_types is missing.

Therefore using lowlevel_cleaner or the delete option in the
recycler will delete files that may be still in use. The
flexFormCallBack must be changed to delete only files of
internal_type "file".

Change-Id: I8519705f2155bf0d49ae10316c6622f670189e28
Fixes: #40052
Releases: master, 6.2
Reviewed-on: http://review.typo3.org/16239
Reviewed-by: Stefan Froemken <froemken@gmail.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>

index 2bf69c7..39972d2 100644 (file)
@@ -4371,8 +4371,8 @@ class DataHandler {
                // Use reference index object to find files in fields:
                $refIndexObj = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ReferenceIndex::class);
                $files = $refIndexObj->getRelations_procFiles($dataValue, $dsArr['TCEforms']['config'], $PA['uid']);
-               // Traverse files and delete them:
-               if (is_array($files)) {
+               // Traverse files and delete them if the field is a regular file field (and not a file_reference field)
+               if (is_array($files) && $dsArr['TCEforms']['config']['internal_type'] === 'file') {
                        foreach ($files as $dat) {
                                if (@is_file($dat['ID_absFile'])) {