Deprecated function: unserialize(): Passing null to parameter #1 ($data) of type string is deprecated

Created on 4 June 2024, 22 days ago
Updated 10 June 2024, 16 days ago

When using PHP 8.1 with D10.1, we get the following decprecation message:

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

Drupal\Core\Entity\Sql\SqlContentEntityStorage->loadFromDedicatedTables(Array, ) (Line: 503)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->mapFromStorageRecords(Array) (Line: 428)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->getFromStorage(Array) (Line: 394)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->doLoadMultiple(Array) (Line: 312)
Drupal\Core\Entity\EntityStorageBase->loadMultiple(Array) (Line: 262)
Drupal\Core\Entity\EntityStorageBase->load('9') (Line: 186)
Drupal\menu_link\Plugin\Menu\MenuLinkField->getEntity() (Line: 118)
Drupal\menu_link\Plugin\Menu\MenuLinkField->getProperty('weight') (Line: 140)
Drupal\menu_link\Plugin\Menu\MenuLinkField->getWeight() (Line: 253)
Drupal\Core\Menu\DefaultMenuLinkTreeManipulators->generateIndexAndSort(Array) (Line: 246)
Drupal\Core\Menu\DefaultMenuLinkTreeManipulators->generateIndexAndSort(Array) (Line: 246)
Drupal\Core\Menu\DefaultMenuLinkTreeManipulators->generateIndexAndSort(Array) (Line: 246)
Drupal\Core\Menu\DefaultMenuLinkTreeManipulators->generateIndexAndSort(Array)
call_user_func(Array, Array) (Line: 149)
Drupal\Core\Menu\MenuLinkTree->transform(Array, Array) (Line: 40)
Drupal\menu_link_weight\MenuParentFormSelector\CshsMenuParentFormSelector->getParentSelectOptionsCshs('menu_link_field:node_field_menulink_2fb1986f-ca6d-4373-9dcb-77c03a75cda3_en', Array, Object) (Line: 52)
Drupal\menu_link_weight\MenuParentFormSelector\CshsMenuParentFormSelector->parentSelectElement('main-menu-en:menu_link_field:node_field_menulink_e0409c25-48d0-4ad0-a3f0-de5743415e96_en', 'menu_link_field:node_field_menulink_2fb1986f-ca6d-4373-9dcb-77c03a75cda3_en', Array) (Line: 145)
Drupal\menu_link\Plugin\Field\FieldWidget\MenuLinkWidget->formElement(Object, 0, Array, Array, Object) (Line: 340)
Drupal\Core\Field\WidgetBase->formSingleElement(Object, 0, Array, Array, Object) (Line: 207)
Drupal\Core\Field\WidgetBase->formMultipleElements(Object, Array, Object) (Line: 111)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 183)
Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm(Object, Array, Object) (Line: 121)
Drupal\Core\Entity\ContentEntityForm->form(Array, Object) (Line: 127)
Drupal\node\NodeForm->form(Array, Object) (Line: 107)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('node_theme_edit_form', Object) (Line: 283)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
// ...

The issue is that options column contains a null value.

This results in many error messages displayed in all pages where we have menu links (also in edit forms).
There is a core issue dealing with this πŸ“Œ Unserialize(): Passing null to parameter #1 ($data) of type string is deprecated in Drupal\Core\Entity\Sql\SqlContentEntityStorage::loadFromSharedTables() Needs work

In hte meantime, maybe the value should be defaulting to an empty array instead of null?

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium Ludo.R Brussels

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

Comments & Activities

Production build 0.69.0 2024