unserialize() error on D10

Created on 29 July 2023, over 1 year ago
Updated 14 November 2023, about 1 year ago

Problem/Motivation

Whenever enabling the module on Drupal 10 I get unserialize(NULL) error.
It happens in web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php, Line 604:

$values[$id][$field_name][$langcode][$property_name] = (!empty($column_attributes['serialize'])) ? unserialize($row[$column_name]) : $row[$column_name];

The full message is this:

Deprecated function: unserialize(): Passing null to parameter #1 ($data) of type string is deprecated in Drupal\Core\Entity\Sql\SqlContentEntityStorage->loadFromSharedTables() (line 604 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Indeed, the table menu_link_content_data has column translated_link_url__options, and the values are all NULL.

Running this

update menu_link_content_data set translated_link_url__options = 'N;';

will fix the issue.

Steps to reproduce

My scenario was following:

  1. Installed D9
  2. Installed multilingual_menu_urls
  3. Created a multilingual external url
  4. Upgraded to D10
  5. Cannot do even drush cr because of the unserialize(NULL) errors.
  6. Fixed by the above update query

It can be repeated:

  1. drush pm-uninstall multilingual_menu_urls
  2. drush en multilingual_menu_urls
  3. drush cr ... and the error appears again.

Proposed resolution

Install hook that takes care of converting that serialized field from NULL to N;.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇪🇪Estonia ragnarkurm

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024