Fix #148 igbinary_serialize cannot serialize resource(stream) #156
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 aresource
cannot be serialized, but theResponse
object still contains thestream
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 ofPsr\Http\Message\StreamInterface
not using aresource
in its internal, as it's meant to fetch data from acallback
. In this implementation I've chosen to create aBodyStore
, 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 theResponse
on__wakeup