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 2 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 #1

Updated by Gerrit Code Review 2 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/+/83011

Actions #2

Updated by Gerrit Code Review 2 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/+/82979

Actions #3

Updated by Oliver Bartsch 2 months ago

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

Also available in: Atom PDF