Issue Bug Resolved

#104083transport_spool_type memory makes install tool fail

Tee Ohh 06/13/24, 07:44 updated 11/02/26, 19:40

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

Reviews 3

History 1217

  1. Georg Ringer commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2024-06-14T10:47:44+00:00" > 06/14/24, 10:47 </span>

    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!

  2. Tee Ohh commented <span data-processor="relativetime" data-value="2024-06-14T11:28:46+00:00" > 06/14/24, 11:28 </span>

    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.

  3. Garvin Hicking commented <span data-processor="relativetime" data-value="2024-06-14T11:58:55+00:00" > 06/14/24, 11:58 </span>

    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?

  4. Tee Ohh commented <span data-processor="relativetime" data-value="2024-06-14T12:08:22+00:00" > 06/14/24, 12:08 </span>

    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.

  5. Garvin Hicking commented <span data-processor="relativetime" data-value="2024-06-14T12:53:20+00:00" > 06/14/24, 12:53 </span>

    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.

  6. Tee Ohh commented <span data-processor="relativetime" data-value="2024-06-17T10:14:36+00:00" > 06/17/24, 10:14 </span>

    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>.</classname>

  7. Tee Ohh commented <span data-processor="relativetime" data-value="2024-06-17T10:30:29+00:00" > 06/17/24, 10:30 </span>

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

  8. Georg Ringer commented and changed status Needs Feedback Accepted <span data-processor="relativetime" data-value="2024-06-17T20:28:41+00:00" > 06/17/24, 20:28 </span>

    thanks for your feedback!
    correct, problem is

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

    in MemorySpool

  9. Georg Ringer changed subject Environment cards can not be loaded anymore transport_spool_type memory makes install tool fail <span data-processor="relativetime" data-value="2024-06-17T20:39:11+00:00" > 06/17/24, 20:39 </span>

  10. Gerrit Code Review pushed patch set 1 for main to change 84777 status Accepted Under Review <span data-processor="relativetime" data-value="2024-06-18T13:22:19+00:00" > 06/18/24, 13:22 </span>

  11. Garvin Hicking commented <span data-processor="relativetime" data-value="2024-06-18T18:00:47+00:00" > 06/18/24, 18:00 </span>

    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) {
  12. Georg Ringer commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-11-02T19:40:14+00:00" > 11/02/26, 19:40 </span>

    Applied in changeset commit:f5d959d6e5354636d94d40ed785013114ef275db.