RTC bug Maintainers Checked PR-4.4-dev Pending

User tests: Successful: Unsuccessful:

avatar AlexanderCkm
AlexanderCkm
15 Feb 2024

Pull Request for Issue #42482.

Summary of Changes

This change addresses a fatal error encountered in the MailerFactory::createMailer method due to the cloning of a Registry object containing closures. The proposed fix involves creating a new Registry instance with the existing $defaultConfiguration instead of cloning it, effectively preventing the "Serialization of 'Closure' is not allowed" error.

Testing Instructions

$app = Factory::getApplication();

// Add a closure to the global configuration.
$closure = function() {};
$app->set('closureTest', $closure);

// Attempt to send mail using the MailerFactory.
$mail = Factory::getMailer();
$mail->clearAttachments()->clearAllRecipients();
$mail->sendMail(
    (string) $app->get('mailfrom'),
    (string) $app->get('fromname'),
    'example@example.com',
    'A test email subject!',
    'A test body.'
);

Actual result BEFORE applying this Pull Request

Attempting to send an email through certain configurations of Joomla 4.x with PHP 8.1 results in a fatal error: "Serialization of 'Closure' is not allowed".

Expected result AFTER applying this Pull Request

The fatal error is resolved, and emails can be sent successfully without encountering the "Serialization of 'Closure' is not allowed" error.

Link to documentations

  • No documentation changes for docs.joomla.org needed
  • No documentation changes for manual.joomla.org needed
avatar AlexanderCkm AlexanderCkm - open - 15 Feb 2024
avatar AlexanderCkm AlexanderCkm - change - 15 Feb 2024
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 15 Feb 2024
Category Libraries
avatar ceford
ceford - comment - 26 Feb 2024

Mind gone blank - where best to plant that sample code?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42819.

avatar AlexanderCkm
AlexanderCkm - comment - 26 Feb 2024

Mind gone blank - where best to plant that sample code?

This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42819.

Apologies, while tidying up the PR, I reordered the test code a bit which meant that the MailerFactory wasn't using the latest application configuration.

$app = Factory::getApplication();

// Add a closure to the global configuration.
$closure = function() {};
$app->set('closureTest', $closure);

// Attempt to send mail using the MailerFactory.
$mail = Factory::getMailer();
$mail->clearAttachments()->clearAllRecipients();
$mail->sendMail(
    (string) $app->get('mailfrom'),
    (string) $app->get('fromname'),
    'example@example.com',
    'A test email subject!',
    'A test body.'
);

I have just tested again within my template's index.php file and have been able to reproduce the problem with the above code. For testing purposes I put it in the index.php file, but it should have the same results no matter where it's placed as long as it gets executed.

avatar AlexanderCkm AlexanderCkm - change - 26 Feb 2024
The description was changed
avatar AlexanderCkm AlexanderCkm - edited - 26 Feb 2024
avatar MacJoom
MacJoom - comment - 28 Feb 2024

Can we have some tests here?

avatar chrisdavenport chrisdavenport - test_item - 29 Feb 2024 - Tested successfully
avatar chrisdavenport
chrisdavenport - comment - 29 Feb 2024

I have tested this item ✅ successfully on b9c7451


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42819.

avatar ceford ceford - test_item - 29 Feb 2024 - Tested successfully
avatar ceford
ceford - comment - 29 Feb 2024

I have tested this item ✅ successfully on b9c7451

I tested with PHP8.3 - error without patch, no error with patch, so I think the test is still valid.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42819.

avatar richard67 richard67 - change - 3 Mar 2024
Status Pending Ready to Commit
Labels Added: bug Maintainers Checked PR-4.4-dev
avatar richard67
richard67 - comment - 3 Mar 2024

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42819.

avatar laoneo laoneo - change - 4 Mar 2024
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2024-03-04 13:06:09
Closed_By laoneo
Labels Added: RTC
avatar laoneo laoneo - close - 4 Mar 2024
avatar laoneo laoneo - merge - 4 Mar 2024
avatar laoneo
laoneo - comment - 4 Mar 2024

Thanks!

Add a Comment

Login with GitHub to post a comment