Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialization of an Exception is not possible inside the closure #76

Closed
borys-p opened this issue Oct 19, 2023 · 1 comment
Closed

Serialization of an Exception is not possible inside the closure #76

borys-p opened this issue Oct 19, 2023 · 1 comment

Comments

@borys-p
Copy link

borys-p commented Oct 19, 2023

Serializable Closure Version

1.3.1

PHP Version

8.2.8

Description

Serialization of an Exception inside the serializable closure results with the Serialization of 'Closure' is not allowed exception. This is most likely caused by an attempt to serialize the stack trace, which contains the serializable closure itself, but this time without the ability to do its magic.

And, frankly, I'm not sure if there's anything that can be done about it, other than adding another warning to the documentation. You can't do much with an already existing Exception object and its stack trace.

Steps To Reproduce

This issue is very easy to reproduce:

$closure = new \Laravel\SerializableClosure\SerializableClosure(function() { return serialize(new \Exception('boom')); });
echo $closure();

This works as expected:

$closure = function() { return serialize(new \Exception('boom')); };
echo $closure();
@driesvints
Copy link
Member

Hi there. I don't think it ever was intended to serialize an exception like this indeed. Can you send in a PR to the docs? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants