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