No Code Attached Yet
avatar chrisdavenport
chrisdavenport
7 Dec 2023

Steps to reproduce the issue

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.

Expected result

No fatal error when attempting to send an email.

Actual result

"Serialization of 'Closure' is not allowed" error.

System information (as much as possible)

Joomla 4.x
PHP 8.1

Additional comments

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.

avatar chrisdavenport chrisdavenport - open - 7 Dec 2023
avatar joomla-cms-bot joomla-cms-bot - change - 7 Dec 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 7 Dec 2023
avatar alikon alikon - close - 15 Feb 2024
avatar alikon
alikon - comment - 15 Feb 2024

please test #42819

avatar alikon alikon - change - 15 Feb 2024
Status New Closed
Closed_Date 0000-00-00 00:00:00 2024-02-15 16:55:08
Closed_By alikon

Add a Comment

Login with GitHub to post a comment