Deprecated function: unserialize(): Passing null to parameter #1

Created on 18 October 2022, over 1 year ago
Updated 19 January 2024, 5 months ago

Describe your bug or feature request.

On upgrade to PHP 8.1 I get the following errors in the log:

Deprecated function: unserialize(): Passing null to parameter #1 ($data) of type string is deprecated in CommerceProductEntityController->attachLoad() (line 130 of C:\wamp64\xxx\sites\all\modules\contrib\commerce\modules\product\includes\commerce_product.controller.inc).

Deprecated function: unserialize(): Passing null to parameter #1 ($data) of type string is deprecated in CommerceCustomerProfileEntityController->attachLoad() (line 121 of C:\wamp64\xxx\sites\all\modules\contrib\commerce\modules\customer\includes\commerce_customer_profile.controller.inc).

Deprecated function: unserialize(): Passing null to parameter #1 ($data) of type string is deprecated in CommercePaymentTransactionEntityController->attachLoad() (line 137 of C:\wamp64\xxx\sites\all\modules\contrib\commerce\modules\payment\includes\commerce_payment_transaction.controller.inc).

If a bug, provide steps to reproduce it from a clean install.

PHP 8.1.0
Drupal core 7.92
Commerce Core 7.x-1.17

I'm not sure this is the best approach, but based on patches I've seen for similar errors in other modules, I did this for each of the three affected files:

- $profile->data = unserialize($profile->data);
+ $profile->data = unserialize($profile->data ?? '');

Everything still seems to work now and the errors are gone, but I have a sneaking suspicion that the real fix is more complicated that this.

Patch coming as soon as I get an issue number.

πŸ› Bug report
Status

RTBC

Version

1.0

Component

Other

Created by

πŸ‡ΊπŸ‡ΈUnited States rclemings

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

    The issue particularly affects sites running on PHP version 8.1.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.69.0 2024