Bug #103051
closedDeleting files in fileadmin via FTP (or similar) can lead to a TypeError with webhook extension
100%
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
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
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
Updated by Oliver Bartsch 2 months ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 19c5f9b237de228210d127bdcfc08a0539215149.