Project

General

Profile

Actions

Bug #101725

closed

Please execute FileDeletionAspect regardless if file is missing or not

Added by Stefan Froemken 8 months ago. Updated 7 months ago.

Status:
Resolved
Priority:
Should have
Category:
File Abstraction Layer (FAL)
Target version:
Start date:
2023-08-22
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.2
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

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.

Actions #1

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.

Actions #2

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

Actions #3

Updated by Stefan Froemken 8 months ago

  • Assignee set to Stefan Froemken
  • Complexity set to easy
Actions #4

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

Actions #5

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

Actions #6

Updated by Stefan Froemken 7 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF