Bug #101725
closedPlease execute FileDeletionAspect regardless if file is missing or not
100%
Description
Hello,
I have a command to delete a lot of related files of a customers table.
The command should remove files older than 3 years.
In some cases the file is already deleted, but the sys_file_reference, sys_file_metadata and maybe the processed data is still available in DB.
While deleting such a record with missing file over official API I get following error message:
You are not allowed to delete the file "pictures/2019/hockey.jpg"
This message is not correct and it has nothing to do with insufficient permissions.
This is my TYPO3 API call:
$fileReference = $resourceFactory->getFileReferenceObject( $sysFileReferenceRecord['uid'], $sysFileReferenceRecord ); $fileReference->getOriginalFile()->getStorage()->deleteFile($fileReference->getOriginalFile());
This is the problem IMO in TYPO3 core. ResourceStorage::checkFileActionPermission
// Check 5: Check the capabilities of the storage (and the driver) if ($isWriteCheck && ($isMissing || !$this->isWritable())) { return false; }
Just a missing file, is not a indication of missing permissions. IMO, we should split these two conditions into separate ones with different return values or throw an exception, if file is missing.
Updated by Stefan Froemken 8 months ago
As a short solution for other developers. You can instantiate the FileDeletionAspect on your own and call "removeFromRepository" with the file object as argument.
Updated by Gerrit Code Review 8 months ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80613
Updated by Stefan Froemken 8 months ago
- Assignee set to Stefan Froemken
- Complexity set to easy
Updated by Gerrit Code Review 7 months ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80613
Updated by Gerrit Code Review 7 months ago
Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81067
Updated by Stefan Froemken 7 months ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset c274c26b68290cf826cbcb8fc630d1dc42abe841.