aus_driver_amazon_s3 icon indicating copy to clipboard operation
aus_driver_amazon_s3 copied to clipboard

CRITICAL Exception: Attempt to modify property "additionalHeaderData" on null in v12

Open Moongazer opened this issue 10 months ago • 1 comments

Since an upgrade to TYPO3 v12, we see occasionally the following exception inside the TYPO3 error-log, resulting from FE requests:

Core: Exception handler (WEB): Uncaught TYPO3 Exception: Attempt to modify property "additionalHeaderData" on null | Error thrown in file .../vendor/andersundsehr/aus-driver-amazon-s3/Classes/Driver/AmazonS3Driver.php in line 1100

Maybe this issue is related to #81 (which happened in TYPO3 v10), but now re-occurring after an upgrade to TYPO v12 (in v11 it never happened). Again, it is the same line of code. The difference is, that in v10 it was a warning, now in v12 its an exception: https://github.com/andersundsehr/aus_driver_amazon_s3/blob/9e5b99600e17bc50504017f6a3bd1e44112ab378/Classes/Driver/AmazonS3Driver.php#L1100

Not sure how $GLOBALS['TSFE'] can be null in some circumstances for FE requests.

Environment: PHP 8.3 TYPO3 12.4.27 aus_driver_amazon_s3 1.13.1

Moongazer avatar Feb 19 '25 11:02 Moongazer

We received multiple user-complaints in the last 10 days about missing emails. It turns out, that this issue is responsible for it, because it randomly breaks a process where an email should be sent out.

Below is a shortened stack-trace which I will summarize here to get an understanding what happens:

  1. It seems that only certain API FE requests are affected (we're using EXT:t3api). But not all! So sometimes a request to /api/v1/user-process is successful, sometimes a request to the same endpoint fails. Btw: all this happens after a login, so a FE user is authorized.
  2. The request triggers the UserFinishedEventListener event if certain conditions are met.
  3. If this event is dispatched, the NotificationService should send an email to the current FE user.
  4. The mail-template contains an image, which is stored in the local resource-folder of our extension (EXT:my_vendor/Resources/Public/Images/Email/customer-referral.png)
  5. Even if the image is local, the TYPO3 ResourceStorage whats to get all processing-folders and calls getProcessingFolders()
  6. In its StorageRepository, the driver "AusDriverAmazonS3" is at the first place, so it is initialized (also if it is not needed)
  7. If then - for whatever reason - $GLOBALS['TSFE'] is null, the requests fails here and no mail is sent to the customer.
// NOTE: here in initializeSettings() in line 1100 the exception is thrown in case $GLOBALS['TSFE'] is null
AmazonS3Driver.php:1100, AUS\AusDriverAmazonS3\Driver\AmazonS3Driver->initializeSettings()
AmazonS3Driver.php:222, AUS\AusDriverAmazonS3\Driver\AmazonS3Driver->initialize()
ResourceStorage.php:271, TYPO3\CMS\Core\Resource\ResourceStorage->__construct()
GeneralUtility.php:2985, TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance()
StorageRepository.php:471, TYPO3\CMS\Core\Resource\StorageRepository->createStorageObject()
StorageRepository.php:369, TYPO3\CMS\Core\Resource\StorageRepository->getStorageObject()
StorageRepository.php:226, TYPO3\CMS\Core\Resource\StorageRepository->findAll()
// NOTE: the ResourceStorage wants to get the processing-foders and its repository contains the driver "AusDriverAmazonS3" at first place, so it is initialized
ResourceStorage.php:1683, TYPO3\CMS\Core\Resource\ResourceStorage->getProcessingFolders()
ResourceStorage.php:2586, TYPO3\CMS\Core\Resource\ResourceStorage->isWithinProcessingFolder()
ResourceStorage.php:1462, TYPO3\CMS\Core\Resource\ResourceStorage->getFileByIdentifier()
ResourceFactory.php:241, TYPO3\CMS\Core\Resource\ResourceFactory->getFileObjectFromCombinedIdentifier()
ResourceFactory.php:318, TYPO3\CMS\Core\Resource\ResourceFactory->retrieveFileOrFolderObject()
ImageService.php:169, TYPO3\CMS\Extbase\Service\ImageService->getImageFromSourceString()
// NOTE: the image is stored as local extension asset (EXT:my_vendor/Resources/Public/Images/Email/customer-referral.png)
ImageService.php:127, TYPO3\CMS\Extbase\Service\ImageService->getImage()
ImageViewHelper.php:158, TYPO3\CMS\Fluid\ViewHelpers\Uri\ImageViewHelper::renderStatic()
partial_CustomerReferral_2c15561ae7f615ba.php:89, partial_CustomerReferral_2c15561ae7f615ba->render()
[...]
layout_DesignSystem_html_9086d05b1aac850d.php:327, layout_DesignSystem_html_9086d05b1aac850d->render()
AbstractTemplateView.php:204, TYPO3Fluid\Fluid\View\AbstractTemplateView->render()
FluidEmail.php:206, TYPO3\CMS\Core\Mail\FluidEmail->renderContent()
FluidEmail.php:182, TYPO3\CMS\Core\Mail\FluidEmail->generateTemplatedBody()
FluidEmail.php:129, TYPO3\CMS\Core\Mail\FluidEmail->ensureValidity()
SentMessage.php:34, Symfony\Component\Mailer\SentMessage->__construct()
AbstractTransport.php:87, Symfony\Component\Mailer\Transport\AbstractTransport->send()
SmtpTransport.php:138, Symfony\Component\Mailer\Transport\Smtp\SmtpTransport->send()
Mailer.php:111, TYPO3\CMS\Core\Mail\Mailer->send()
MailService.php:90, Vendor\Core\Service\MailService->send()
NotificationService.php:273, Vendor\Core\Service\NotificationService->sendUserFinishedMail()
UserFinishedEventListener.php:71, Vendor\Core\EventListener\User\UserFinishedEventListener->__invoke()
[...]
T3apiRequestResolver.php:30, SourceBroker\T3api\Middleware\T3apiRequestResolver->process()
MiddlewareDispatcher.php:162, {anonymous-class:/var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php:128-164}->handle()
PrepareTypoScriptFrontendRendering.php:58, TYPO3\CMS\Frontend\Middleware\PrepareTypoScriptFrontendRendering->process()
MiddlewareDispatcher.php:162, {anonymous-class:/var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php:128-164}->handle()
TypoScriptFrontendInitialization.php:112, TYPO3\CMS\Frontend\Middleware\TypoScriptFrontendInitialization->process()
MiddlewareDispatcher.php:162, {anonymous-class:/var/www/html/vendor/typo3/cms-core/Classes/Http/MiddlewareDispatcher.php:128-164}->handle()
PageArgumentValidator.php:113, TYPO3\CMS\Frontend\Middleware\PageArgumentValidator->process()
[...]
index.php:21, {main}()

Workaround: For now, we disabled the frontend.dnsPrefetch option, so this line can't be executed anymore. Surely it is not an optimal solution.

Moongazer avatar Feb 28 '25 16:02 Moongazer

Hi there. Checked some circumstances, and i think it is ok, if for some reason TSFE is not our expected TypoScriptFrontendController we do not set the dns prefetch link. This is not essential.

Fixed in master and in TYPO3v13 branch. Created 1.13.4 prerelease. Thank you for reporting.

weakbit avatar Jul 21 '25 14:07 weakbit