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

Created on 11 August 2023, 11 months ago
Updated 17 August 2023, 11 months ago

Problem/Motivation

In PHP 8.1 I catched PHP warning:
Deprecated function: unserialize(): Passing null to parameter #1 ($data) of type string is deprecated in Bean->setFields() (line 235 of .../modules/contrib/bean/includes/bean.core.inc).

Steps to reproduce

1) Go to 'block/add' page.
2) Add any block.

Proposed resolution

Add condition in the case when $this->data = null for the code in setFields() method for Bean class:
$values = is_array($this->data) ? $this->data : unserialize($this->data);

For example:
$values = is_array($this->data) || is_null($this->data) ? $this->data : unserialize($this->data);
or
$values = !is_string($this->data) ? $this->data : unserialize($this->data);

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡§πŸ‡ΎBelarus alena_stanul

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

Production build 0.69.0 2024