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

Fix #148 igbinary_serialize cannot serialize resource(stream) #156

Merged
merged 2 commits into from
Jan 31, 2022

Conversation

xavierleune
Copy link
Contributor

When using igbinary_serialize in the process to store a CacheEntry, we can get the following warning from PHP: Message: igbinary_serialize(): Cannot serialize resource(stream) and resources may be converted to objects that cannot be serialized in future php releases. Serializing the value as null instead. CacheEntry already mitigates the fact that a resource cannot be serialized, but the Response object still contains the stream so the warning is still there.

As a workaround, I propose to replace the resource with an instance of GuzzleHttp\Psr7\PumpStream, the only implementation of Psr\Http\Message\StreamInterface not using a resource in its internal, as it's meant to fetch data from a callback. In this implementation I've chosen to create a BodyStore, with the very minimal logic to return expected data when invoked.

By using this new implementation of Psr\Http\Message\StreamInterface for the body, we can totally remove the need to manipulate the Response on __wakeup

Copy link
Owner

@Kevinrob Kevinrob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR.
LGTM

src/CacheEntry.php Outdated Show resolved Hide resolved
src/CacheEntry.php Show resolved Hide resolved
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

Successfully merging this pull request may close these issues.

None yet

3 participants