Deprecated function: json_decode(): Passing null to parameter #1 ($json) in gutenberg_form_node_form_alter()

Created on 5 May 2023, almost 2 years ago
Updated 12 September 2023, over 1 year ago

Problem/Motivation

On php 8.1 I get the following error:
Deprecated function: json_decode(): Passing null to parameter #1 ($json) of type string is deprecated in gutenberg_form_node_form_alter() (line 455 of modules/contrib/gutenberg/gutenberg.module).

We should probably check the value of $json variable before passing it to json_decode

Proposed resolution

To fix this change line 453 from:
$gutenberg_template = json_decode($config->get($node_type . '_template'));

To:

  $gutenberg_template_json = $config->get($node_type . '_template');
  $gutenberg_template = $gutenberg_template_json ? json_decode($gutenberg_template_json) : null;

I may provide a patch later

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

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

Comments & Activities

Production build 0.71.5 2024