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

Created on 18 October 2022, over 2 years ago
Updated 31 January 2023, about 2 years 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

Needs review

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.

  • πŸ‡ΈπŸ‡ͺSweden pontus.froden

    Patch in #11 works for me.

  • πŸ‡ΊπŸ‡ΈUnited States rszrama

    Any sense of why these values are NULL to begin with?

  • Status changed to RTBC over 1 year ago
  • πŸ‡³πŸ‡±Netherlands cmseasy

    Patch #11 works for me too on php 8.1.
    Changed to RTBC.

  • Issue was unassigned.
  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    Resolves the problems for me too.

    As a reminder, after finishing your work on an issue please set the "assigned" field back to "unassigned". Thank you.

  • πŸ‡ΊπŸ‡ΈUnited States hargobind Austin, Texas

    Also resolves the errors on my sites.

    @rszrama: Any sense of why these values are NULL to begin with?

    The "data" column on these tables is NULL for most rows on each of those tables on my sites. Not sure what the expected behavior is in the code, but that's what I'm seeing in the database.

  • Status changed to Needs review about 2 months ago
  • πŸ‡ΊπŸ‡ΈUnited States hargobind Austin, Texas

    Three of the fixes in the #11 patch have already been committed 2 months ago via 3c53c87a, 2623a4a5, and b035d1fe.

    Attaching a patch that contains the remaining fixes, and uses a similar code style to those prior commits.

Production build 0.71.5 2024