The problem occurs in the MailerFactory::createMailer method. This attempts to clone the $defaultConfiguration which is a Registry that includes the data from configuration.php as well as the system DI container. If this DI container happens to contain an anonymous function (closure) then the clone statement fails with a fatal "Serialization of 'Closure' is not allowed" error.
I'm not sure how you can set up a simple test for this. In my case I was using League Tactician as a command bus, but that's a lot of code to have to set up for a test.
No fatal error when attempting to send an email.
"Serialization of 'Closure' is not allowed" error.
Joomla 4.x
PHP 8.1
The fix is quite simple. Just replace
$configuration = clone $this->defaultConfiguration;
with
$configuration = new Registry($this->defaultConfiguration);
in /libraries/src/Mail/MailerFactory.php
. The Registry class itself will produce a copy which safely copies closures.
Labels |
Added:
No Code Attached Yet
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2024-02-15 16:55:08 |
Closed_By | ⇒ | alikon |
please test #42819