Thanks to visit codestin.com
Credit goes to github.com

Skip to content

5.2.5 regression on sending email Serialization of 'Closure' is not allowed #40445

Closed
@PhilETaylor

Description

@PhilETaylor

Symfony version(s) affected: 5.2.5

Description
On a normally working Symfony project, we send an email on user login
After upgrading to Symfony 5.2.5 this now creates an error

Screenshot 2021-03-11 at 12 46 44

How to reproduce

I think the cause is passing in Entities and Objects to the context, which might have closures in them.

Im passing into the context the User object and the LoginSuccessEvent event in my live app.

You can replicate this by changing the UnitTest to have a closure in the context of the templated email as follows, this will result in the broken unit test with the same error Im experiencing.

// changing the testRenderedOnce test you can replicate this 

 $closure = function ($name){
            return $name;
        };

        $email = (new TemplatedEmail())
            ->to('[email protected]')
            ->from('[email protected]')
            ->context(['event'=>$closure])
        ;

Screenshot 2021-03-11 at 13 12 15

Possible Solution
re-review of #39733 which was added in 5.2.5 and the error message relates to.

Additional context
Transport is a standard SMTP.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions