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

__debugInfo fails after unserialize() #44

Closed
assertchris opened this issue Mar 10, 2015 · 5 comments
Closed

__debugInfo fails after unserialize() #44

assertchris opened this issue Mar 10, 2015 · 5 comments

Comments

@assertchris
Copy link

SerializableClosure::serialize() does not account for SerializerInterface $serializer = null, in the constructor. If this parameter isn't provided then the default serializer, which the constructor creates, is not created during SerializableClosure::unserialize().

PHP Fatal error:  Call to a member function getData() on null in /[redacted]/vendor/jeremeamia/SuperClosure/src/SerializableClosure.php on line 164
PHP Stack trace:
PHP   1. {main}() /[redacted]/debug.php:0
PHP   2. print_r() /[redacted]/debug.php:20
PHP   3. SuperClosure\SerializableClosure->__debugInfo() /[redacted]/debug.php:20

Fatal error: Call to a member function getData() on null in /[redacted]/vendor/jeremeamia/SuperClosure/src/SerializableClosure.php on line 164

Call Stack:
    0.0003     230504   1. {main}() /[redacted]/debug.php:0
    0.0308    3387808   2. print_r() /[redacted]/debug.php:20
    0.0308    3388216   3. SuperClosure\SerializableClosure->__debugInfo() /[redacted]/debug.php:20
@travisulrich
Copy link

I also ran across this issue yesterday. var_dump works successfully on the serialized object, but print_r causes the error @assertchris mentioned above.

@Anahkiasen
Copy link

Small reproducible test case:

$closure = new SuperClosure\SerializableClosure(function() {});
var_dump($closure); // Works

$closure = unserialize(serialize($closure));
var_dump($closure); // Crashes

@GrahamCampbell
Copy link
Contributor

@Anahkiasen Surely $closure = unserialize(serialize($closure))->getClosure(); is the correct usage here?

@jeremeamia
Copy link
Owner

Thanks for the bug report and repro code.

@Anahkiasen
Copy link

@GrahamCampbell Not that I know of no, the SerializableClosure wraps the closure and is still callable, it's more like a decorator

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

No branches or pull requests

5 participants