Bug #84110
closedFiles are deleted when a new record version is published
0%
Description
Lets assume we have a custom domain element with a column that is defined like this:
'sample_file' => array( 'exclude' => 0, 'label' => 'Sample File', 'config' => array( 'type' => 'group', 'internal_type' => 'file', 'uploadfolder' => 'uploads/tx_myextension/sampeFiles', 'show_thumbs' => 1, 'size' => 1, 'allowed' => 'gif,jpg,jpeg', 'disallowed' => '', 'maxitems' => 1 ), ),
When a record is created, the file can be uploaded and is stored in the upload folder. Now let’s assume this record is edited in a workspace (any field can be changed, but the sample file is unchanged). After the changes have been made, the record is published to the live workspace.
Unfortunately, as soon as the record is published, the file is deleted from the upload folder. This happens when versions for the published records are deleted. The code is located in \TYPO3\CMS\Core\DataHandling\DataHandler. In the function deleteRecord all fields that holds references to files are fetched, after that, all files are deleted without any further check.
Before a file is deleted, there should be a check if the file is not referenced by another record. Only if no other reference can be found, the file should really be deleted.