[D7 PHP 8.1] Deprecated Serializable interface - update libphonenumber to ^8.12.

Created on 27 May 2024, 6 months ago

Problem/Motivation

When updating the Drupal website to PHP 8.1, we get these warnings:

Deprecated function: libphonenumber\PhoneNumber implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in include() (line 5 of /SITE_DIR/sites/all/vendor/giggsey/libphonenumber-for-php/src/libphonenumber/PhoneNumber.php).

Steps to reproduce

  1. Update a Drupal 7 website to PHP 8.1
  2. Save a node with phone number validation
  3. See the error message

Proposed resolution

  1. Upgrade giggsey/libphonenumber-for-php to ^8.12

Remaining tasks

Decide on how to which version to upgrade to.
Ensure that the module still works with the upgraded version.

User interface changes

None.

API changes

TBD.

Data model changes

None.

Feature request
Status

Needs review

Component

Code

Created by

🇨🇦Canada Nathan Tsai

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

Merge Requests

Comments & Activities

  • Issue created by @Nathan Tsai
  • Assigned to Nathan Tsai
  • 🇨🇦Canada Nathan Tsai

    Upgraded to "giggsey/libphonenumber-for-php": "^8.12".

    Then had to:

    1. Update the consolidated composer.json file.
    2. Then run composer update in the file directory /SITE_DIR/sites/default/files/composer (which is the path listed at /admin/config/system/composer-manager/settings)

    Now the error is gone, but when I go to /admin/config/system/composer-manager, I get:

        Warning: Undefined array key "name" in composer_manager_installed_packages() (line 325 of /SITE_DIR/sites/all/modules/composer_manager/composer_manager.admin.inc).
        Warning: Undefined array key "version" in composer_manager_installed_packages() (line 326 of /SITE_DIR/sites/all/modules/composer_manager/composer_manager.admin.inc).
        Warning: Trying to access array offset on value of type bool in composer_manager_installed_packages() (line 325 of /SITE_DIR/sites/all/modules/composer_manager/composer_manager.admin.inc).
        Warning: Trying to access array offset on value of type bool in composer_manager_installed_packages() (line 326 of /SITE_DIR/sites/all/modules/composer_manager/composer_manager.admin.inc).
        Warning: Undefined array key "name" in composer_manager_installed_packages() (line 325 of /SITE_DIR/sites/all/modules/composer_manager/composer_manager.admin.inc).
        Warning: Undefined array key "version" in composer_manager_installed_packages() (line 326 of /SITE_DIR/sites/all/modules/composer_manager/composer_manager.admin.inc).
        The following packages must be installed: giggsey/libphonenumber-for-php
        Refer to the instructions on the Composer Manager project page for updating packages.
    
  • 🇨🇦Canada Nathan Tsai

    Requires [3247179] in order to fix the warnings.

    1. Apply patch https://git.drupalcode.org/project/composer_manager/-/merge_requests/6.diff in [3247179]
    2. Upgrade giggsey/libphonenumber-for-php to ^8.12
    3. Add instructions for users to then:
      1. Update the consolidated composer.json file at /admin/config/system/composer-manager
      2. Run composer update in the file directory /SITE_DIR/sites/default/files/composer
      • (which is the path listed at /admin/config/system/composer-manager/settings)
  • Merge request !7Resolve #3450183 "D7 php 8.1" → (Open) created by Nathan Tsai
  • Issue was unassigned.
  • Status changed to Needs review 6 months ago
Production build 0.71.5 2024