Project

General

Profile

Actions

Bug #101725

closed

Please execute FileDeletionAspect regardless if file is missing or not

Added by Stefan Froemken 9 months ago. Updated 8 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

Also available in: Atom PDF