[php-src] Issue #7939: Cannot serialize IntlTimeZone objects

From: Date: Mon, 17 Jan 2022 09:55:22 +0000
Subject: [php-src] Issue #7939: Cannot serialize IntlTimeZone objects
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-239055@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/7939 Comment Author: drjayvee I was under the naive assumption that every class supports serialization, unless it's especially tricky. Our particular use case is: ```php class LocaleConfiguration { public IntlTimeZone $timeZone = null; public string $locale = 'en-US'; public int $firstWeekDay = 1; // etc } ``` And then cache the user's configuration in their session, memory cache, or elsewhere. The simple yet awkward workaround is ```php public function __serialize(): array { return [ 'timeZone' => $this->timeZone->getID(), 'locale' => $this->locale, 'firstWeekDay' => $this->firstWeekDay, // etc ]; } // reverse for __unserialize() ```

« previous php.bugs (#239055) next »