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.

Comments

solideogloria created an issue. See original summary.

solideogloria’s picture

Status: Active » Needs review
StatusFileSize
new3.29 KB
damienmckenna’s picture

Excellent work debugging this, thank you!

I think the minor requirements bump for 7.x-3.x is an agreeable balance in backwards compatibility, in the Year of Our Cat 2022.

solideogloria’s picture

Especially since PHP 5.2 is prior to the currently recommended secure PHP requirement for Drupal 7.

I spent basically all day on this. Thank God I figured out a solution, because this was annoying. Fortunately, the page that triggered this error for me was a low-traffic page for a content moderator.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community

I ran into this as well, clearing cache and rebuilding registry didn't seem to help. Thanks @solideogloria for spending your time on this!

damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed
Parent issue: » #3308472: Plan for Date 7.x-3.0-alpha3

Committed. We might even bump Date API to require PHP 7, but for now this is a reasonable start. Thanks solideogloria!

damienmckenna’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.