Invalid serialization data for DateTime object; Remove support for PHP < 5.3

Created on 12 September 2022, about 2 years ago
Updated 28 January 2023, almost 2 years ago

Problem/Motivation

After updating to 7.x-3.0-alpha2, I have problems when DateObject is serialized or unserialized. Once the error occurs, if your data was serialized and stored in the session, then viewing any page becomes impossible, as it will try to unserialize the data to view the page.

See comments #32 through #37 here: https://www.drupal.org/project/date/issues/3019527#comment-14689812

I found there is an exception being thrown Invalid serialization data for DateTime object

Steps to reproduce

The code says this:

   * We are extending a core class and core classes cannot be serialized.
   ...
   * @see http://bugs.php.net/41334
   * @see http://bugs.php.net/39821

However, following those links clarifies that not being able to serialize built-in objects has been fixed in PHP 5.3. I tried removing the __sleep() and __wakeup() magic methods, and it fixed the errors.

Proposed resolution

I propose that 7.x-3.x drop support for PHP < 5.3, and then remove the custom serialization functions.

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
  • PHP 5.2

    The issue particularly affects sites running on PHP version 5.2.0 or later.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024