Re: note 105525 deleted from datetime.construct by salathe

From: Date: Thu, 25 Aug 2011 19:20:41 +0000
Subject: Re: note 105525 deleted from datetime.construct by salathe
References: 1 2 3  Groups: php.notes 
Request: Send a blank email to php-notes+get-182734@lists.php.net to get a copy of this message
On 25 August 2011 19:16, Daniel P. Brown <daniel.brown@parasane.net> wrote: >    I'm just glancing at it, but what part of the code is bad here? DateTime doesn't have a __toString() method, nor does the child class add one. > > > On Thu, Aug 25, 2011 at 04:44,  <salathe@php.net> wrote: >> 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'); >>        } >> } >> >> -- >> PHP Notes Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > > > -- > </Daniel P. Brown> > Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting > (866-) 725-4321 > http://www.parasane.net/ > > -- > PHP Notes Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.notes (#182734) next »