Issue with Unserialization in CacheDefinitionCache after latest commit
Closed this issue · 1 comments
Jon78 commented
After upgrading this package we get
unserialize(): Error at offset 0 of 13774 bytes {"exception":"[object] (ErrorException(code: 0): unserialize(): Error at offset 0 of 13774 bytes at /srv/production/vendor/stevebauman/purify/src/Cache/CacheDefinitionCache.php:188)
Line 188 corresponds to return unserialize($encoded);
The introduction of base64 encoding in encode()
and decode()
in 6.1.2 is likely causing compatibility issues with previously cached data.
Possible solution suggested by AI (not tested in any way):
protected function decode($def)
{
// First, try to base64 decode and then unserialize.
if ($encoded = base64_decode($def, true)) {
$decoded = @unserialize($encoded);
if ($decoded !== false || $encoded === 'b:0;') {
return $decoded;
}
}
// Fallback to direct unserialization for backward compatibility.
return @unserialize($def);
}
stevebauman commented