note 105525 deleted from datetime.construct by salathe
| From: | salathe@php.net | Date: | Thu, 25 Aug 2011 08:44:01 +0000 |
| Subject: | note 105525 deleted from datetime.construct by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-182713@lists.php.net to get a copy of this message | ||
Note Submitter: carlos dot vini at gmail dot com
Reason: bad code
----
Before version 5.3 DateTime loses the value if it's serialized. Here's a fix:
class Serializable_DateTime extends DateTime {
private $_serializedValue;
public function __wakeUp() {
parent::__construct($this->_serializedValue);
unset($this->_serializedValue);
}
public function __sleep() {
$this->_serializedValue = $this->__toString();
return array('_serializedValue');
}
}