You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the example code, the ShouldQueue interface and the InteractsWithQueue trait make the listener execute in a queue.
Description
The problem is that the package events don't use the SerializesModels trait which leads to the following problem: Serialization of 'Closure' is not allowed.
Reproduction
// For reproduction, just make an Event listener for any of the package events.// The listener must implement `ShouldQueue` and use `InteractsWithQueue`.// After that dispatch the event and it should result in an exception `Serialization of 'Closure' is not allowed`.
I'm not particularly sure why the problem happens, to be honest.
I tried updating the package's event code to use the SerializesModels trait and my code started working.
I also tried reproducing it in a Vanilla Laravel installation and couldn't do it.
This may be because the User model in my original project is too complex.
It utilizes 10 different traits, attribute functions, scopes, and many more.
DarkGhostHunter
changed the title
[2.0] Exception "Serialization of 'Closure' is not allowed" in event Listeners.
[2.0] Include SerializesModels in events.
May 16, 2024
PHP & Platform
8.3.6 - Linux Mint 21.3 Cinnamon x64
Database
MySQL 8.0.32
Laravel version
11.7.0
Have you done this?
Expectation
Your package has several events.
When I write an event Listener for those, I expect to be able to run the Listeners in a queue like this:
In the example code, the
ShouldQueue
interface and theInteractsWithQueue
trait make the listener execute in a queue.Description
The problem is that the package events don't use the
SerializesModels
trait which leads to the following problem:Serialization of 'Closure' is not allowed
.Reproduction
Stack trace & logs
The text was updated successfully, but these errors were encountered: