Project

General

Profile

Actions

Bug #103051

closed

Deleting files in fileadmin via FTP (or similar) can lead to a TypeError with webhook extension

Added by Lars Peter Søndergaard 3 months ago. Updated 3 months ago.

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

100%

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

Description

This is a bit of an obscure issue I encountered why try to add upload functionality to a frontend Extbase extension.

I understand that in normal situations, I probably won't delete any files manually from the fileadmin directory, and it only happened during my development phase.

My situation is a simple image upload, with the "rename" duplication behaviour.

I use TYPO3\CMS\Core\Resource\Folder->addUploadedFile to move the upload file into the target folder.

During this process ResourceStorage->addFile is called, which triggers the AfterFileAddedEvent event, that the webhooks Extension is listening to.

I encountered the issue, that a just added File is marked as missing (in the DB), and without getting updated is passed to the AfterFileAddedEvent event. This results in File->getPublicUrl returning null, which is not accepted by the TYPO3\CMS\Webhooks\Message\FileAddedMessage class, that only accepts strings for the publicUrl - resulting in a TypeError.

Uncaught TYPO3 Exception TYPO3\CMS\Webhooks\Message\FileAddedMessage::__construct(): Argument #3 ($publicUrl) must be of type string, null given, called in /.../cms-webhooks/Classes/Message/FileAddedMessage.php on line 44
thrown in file /.../cms-webhooks/Classes/Message/FileAddedMessage.php
in line 35

I attached a simple cli command to demonstrate the issue.

Intuitively I'd say that adding a file should probably (always?) set the missing column to 0.


Files

FalTestCommand.php (2.15 KB) FalTestCommand.php Lars Peter Søndergaard, 2024-02-05 14:12
Actions

Also available in: Atom PDF