Project

General

Profile

Actions

Story #97528

open

Add check for references and safe way to delete files in FAL to public API

Added by Sybille Peters over 2 years ago.

Status:
New
Priority:
Should have
Category:
File Abstraction Layer (FAL)
Target version:
-
Start date:
2022-05-02
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
Sprint Focus:

Description

Status: In progress, I can split this up into individual patches.


Add public functionality to

  • check if there are references to a file / within a folder (see also FileList::makeRef, ExtendedFileUtility::func_delete and ExtendedFileUtility::folderHasFilesInUse)
  • return the references to a file
  • "safely" delete a file / folder (checking for references)

If possible, use this functionality instead of having duplicate code or move the functionality to the public API and then use the function there:

  • FileList::makeRef: count number of references
  • ExtendedFileUtility::func_delete: checking for references
  • ExtendedFileUtility::transformFileReferenceToRecordReference

Add phpdoc / documentation note pointing out that a check for references is not performed when deleting a file in

Add phpdoc / documentation note that this function only handles references within the sys_file_references table. TYPO3 - when performing functionality which concern references (including soft references) typically uses sys_refindex in combination with sys_file_references (which will also consider the soft references) - depending on where this functionality is used, we might want to check for both. In any case, it might make sense to point this out here:

A similar note in phpdoc does exist in LocalDriver::deleteFile:

  • This does not check if the file is
  • still used or if it is a bad idea to delete it for some other reason
  • this has to be taken care of in the upper layers (e.g. the Storage)!

In TYPO3, there is functionality to delete files, but the function ExtendedFileUtility::func_delete() which does it safely by checking the references has the problem that it is "internal" and not public and also it sends flash messages (which might be a problem if called from CLI command).

The functionality which is public and usable does not check for references (as it is used as lowlevel functionality). AFAIK there is not public API which safely handles the deletion.

Also, there is no phpdoc that points out that it does not (except in the lower level driver functions).

AFAIK, there is no publicly available function which checks for references. The checking for references is done directly in the the code (e.g. in ExtendedFileUtility::func_delete.

So effectively, you have to handle this yourself - which might result in it being done incorrectly and adds lots of internal TYPO3 functionality to code, making it less maintainable. Also, it is a bit complicated to handle sys_refindex and sys_file_references, see also ExtendedFileUtility::func_delete - so that would be really helpful to have some public API functions.

No data to display

Actions

Also available in: Atom PDF