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

Can't serialize/unserialize more than once #40

Closed
df999 opened this issue Oct 19, 2019 · 4 comments
Closed

Can't serialize/unserialize more than once #40

df999 opened this issue Oct 19, 2019 · 4 comments
Labels

Comments

@df999
Copy link

df999 commented Oct 19, 2019

Hey there, for some reason, it returns boolean true when I try to serialize an object the 2nd time in a row.

Example:

$x = (object)['foo'=>'bar'];

$s = Opis\Closure\serialize($x);
echo $s; // O:8:"stdClass":1:{s:3:"foo";s:3:"bar";}   (CORRECT)

$u = Opis\Closure\unserialize($s);
$s2 = Opis\Closure\serialize($u);
echo $s2; // b:1;   (WRONG - why isn't it the same as above?)

Why does the second serialization produce boolean true?

I'm using the latest opis/closure with PHP 7.3.8 on Win10.

Thanks!

@msarca
Copy link
Member

msarca commented Oct 19, 2019

This is pretty weird. When I've tried to run that code in a PHPUnit test, the error was there. But when I ran the exactly same code outside PHPUnit, it worked. Are you running this code as part of a PHPUnit test?

@df999
Copy link
Author

df999 commented Oct 19, 2019

Thanks for looking into it!

Not in unit tests, no. I'm actually just running it in an old Codeigniter setup. I think it was working for the longest time, but then something happened and I can't imagine what I changed (other than regular customer development). I did change the data structure I was serializing a bit, but since this fails on the simplest of objects, I don't think that could be it.

I didn't change any Opis Closure related code or includes so it must be something else...

@msarca msarca added the bug label Oct 19, 2019
@msarca
Copy link
Member

msarca commented Oct 19, 2019

Fixed in v.3.4.1. Thanks for reporting this bug.

@msarca msarca closed this as completed Oct 19, 2019
@df999
Copy link
Author

df999 commented Oct 19, 2019

That's great - thanks so much!

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

No branches or pull requests

2 participants