note 117329 deleted from class.splobjectstorage by cmb
| From: | cmb@php.net | Date: | Fri, 22 May 2015 17:54:49 +0000 |
| Subject: | note 117329 deleted from class.splobjectstorage by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-202642@lists.php.net to get a copy of this message | ||
Note Submitter: kris dot lamote at it-kitchen dot be
----
For anyone having issues with SplObjectStorages containing corrupt member variables after garbage
collection (FatalErrorException after serializing): we used following fix to great effect
<?php
class FixedSplObjectStorage extends SplObjectStorage
{
public function serialize()
{
$goodPortion = 'N;;m:a:0:{}';
$startKey = 'N;;m:a:';
$serialized = parent::serialize();
$startPos = strpos($serialized, $startKey);
if ($startPos !== false) {
$serialized = substr_replace($serialized, $goodPortion, $startPos, -1);
}
return $serialized;
}
}
?>