Project

General

Profile

Actions

Bug #104083

open

transport_spool_type memory makes install tool fail

Added by Tee Ohh 5 months ago. Updated about 1 month ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
Backend API
Target version:
Start date:
2024-06-13
Due date:
% Done:

0%

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

Description

After the update to TYPO3 12.4.16 is is no longer possible to open the Environment backend module. The following error returned in the request http://domain.com/typo3/install.php?install%5Bcontroller%5D=environment&install%5Bcontext%5D=backend&install%5Baction%5D=cards

Uncaught Error: Cannot instantiate interface TYPO3\CMS\Core\Mail\MailerInterface in /var/www/html/vendor/typo3/cms-core/Classes/Utility/GeneralUtility.php:2985
Stack trace:
#0 /var/www/html/vendor/typo3/cms-core/Classes/Mail/MemorySpool.php(72): TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance()
#1 [internal function]: TYPO3\CMS\Core\Mail\MemorySpool->__destruct()
#2 {main}
thrown in /var/www/html/vendor/typo3/cms-core/Classes/Utility/GeneralUtility.php on line 2985

Actions #1

Updated by Georg Ringer 5 months ago

  • Status changed from New to Needs Feedback

thanks for creating the issue. can you help to me to reproduce the issue by answering the following questions:

  • are you using an installation based on composer or the old way by downloading tar.gz/zip und use that?
  • did you clear all caches in Install Tool?
  • can you maybe test that on a clean installation?

thanks a lot!

Actions #2

Updated by Tee Ohh 5 months ago

As a quick reply
  • I have a composer based installation
  • I cleared all caches in the Backend > Admin Tools > Maintenance > Flush cache and also on command line with `vendor/bin/typo3 cache:flush`
  • I also run `composer dump-autoload`
  • I have the same issue on 2 different composer based TYPO3 12 installations
  • Both installatiosn run inside an ubuntu docker container on a Windows 10 developer maschine

The error still exists.

Actions #3

Updated by Garvin Hicking 5 months ago

Hi!

Can you tell some more specifics about your installation, especially how your TYPO3_CONF_VARS['MAIL'] is set?

Are you able to reproduce this in a vanilla composer installation without extension and customizations?

To me this sounds like either a problem with composer autoloading or with the way how a middleware or something else tries to access the Mailer, which might be related to custom code.

Are you maybe able to share your docker container for inspection?

Actions #4

Updated by Tee Ohh 5 months ago

I made now a complete fresh installation with `composer create-project "typo3/cms-base-distribution:^12.4" my-new-project` in a ubuntu docker container on the same Windows 10 developer maschine and there it runs now fine. No error. Okay. I need to investigate my existing development installations. I need to check my mail configuration.

Actions #5

Updated by Garvin Hicking 5 months ago

Alright, thanks for the feedback - yes, first I'd check your MAIL config setup, and next all possible middlewares and custom event listeners. Hope you can investigate, let us know.

You seem to be using a specific Memory Spooler for Mails, maybe the classloading here doesn't work properly. I don't know though which specific 12.4.16 commit could've influenced the DI/autoloading here.

Actions #6

Updated by Tee Ohh 5 months ago

Finally I found the issue. It has nothing to do with my custom code. This error happends, if you configure `TYPO3_CONF_VARS\MAIL\transport_spool_type = memory` instead of no configuration.

Throws the error "Uncaught Error: Cannot instantiate interface TYPO3\CMS\Core\Mail\MailerInterface in /var/www/html/vendor/typo3/cms-core/Classes/Utility/GeneralUtility.php:2985"

<?php
return [
        'transport_spool_type' => 'memory',
    ],
];

Runs fine

<?php
return [
        'transport_spool_type' => '',
    ],
];

For me, this looks like a bug in the TYPO3 source. Maybe this setting is outdated and should not be configured. But it is still in the "Configure Installation-Wide Options" together with the options: file, memory or <classname>.

Actions #7

Updated by Tee Ohh 5 months ago

I also check the TYPO3 version 12.4.15 and 12.4.14 and there is the same error.

Actions #8

Updated by Georg Ringer 5 months ago

  • Status changed from Needs Feedback to Accepted

thanks for your feedback!
correct, problem is

// TODO: DI should be used to inject the MailerInterface
        $mailer = GeneralUtility::makeInstance(MailerInterface::class);

in MemorySpool

Actions #9

Updated by Georg Ringer 5 months ago

  • Subject changed from Environment cards can not be loaded anymore to transport_spool_type memory makes install tool fail
Actions #10

Updated by Gerrit Code Review 5 months ago

  • Status changed from Accepted 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/+/84777

Actions #11

Updated by Garvin Hicking 5 months ago

I believe the problem is that in the Install Tool > Environment, the framework doesn't really utilize Dependency Injection "properly", because it's in failsafe-mode.

Since probably utilizing "real DI" in this case won't work as intended, I'm afraid the fix might be to prevent calling the __destruct() method and sending mails when being inside the install tool context will very likely fail.

Here's a patch that would circument this, but I'm not sure in which cases the MemorySpool Mailer is currently broken, too. Maybe you want to check if regular mails still get sent with the patch applied (I think so).

Personally, I think the MemorySpool Mailer is not a good idea. It can easily lose mails. I'd strongly suggest to either use no spooler at all (and use a satellite mail relay on localhost) or the file spooler, which doesn't use __destruct logic.

diff --git a/typo3/sysext/core/Classes/Mail/MemorySpool.php b/typo3/sysext/core/Classes/Mail/MemorySpool.php
index 5fee22ddba..a275d307ec 100644
--- a/typo3/sysext/core/Classes/Mail/MemorySpool.php
+++ b/typo3/sysext/core/Classes/Mail/MemorySpool.php
@@ -69,7 +69,13 @@ class MemorySpool extends AbstractTransport implements SingletonInterface, Delay
     public function __destruct()
     {
         // TODO: DI should be used to inject the MailerInterface
-        $mailer = GeneralUtility::makeInstance(MailerInterface::class);
+        try {
+            $mailer = GeneralUtility::makeInstance(MailerInterface::class);
+        } catch (\Throwable $exception) {
+            // Install Tool has no DI setup. Thus also $this->logger is not usable here. Just bail.
+            return;
+        }
+
         try {
             $this->flushQueue($mailer->getRealTransport());
         } catch (TransportExceptionInterface $exception) {

Actions #12

Updated by Gerrit Code Review about 1 month ago

Patch set 2 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/+/84777

Actions

Also available in: Atom PDF