Problem/Motivation

Updating db results in
> [notice] Update started: block_class_update_20004
> [error] json_decode(): Argument #1 ($json) must be of type string, array given

Steps to reproduce

Drupal 11.3.8
Block class 4.0.2

CommentFileSizeAuthor
Bildschirmfoto 2026-04-24 um 12.13.52.png136.75 KBumac_de

Comments

umac_de created an issue. See original summary.

umac_de’s picture

Status: Active » Fixed

Replacing
// Get the array from JSON.
$block_classes_stored = Json::decode($block_classes_stored);

with
// Get the array from JSON if string.
if (is_string($block_classes_stored)) {
$block_classes_stored = Json::decode($block_classes_stored);
}

solved it for me.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

dydave’s picture

Thanks @umac_de for raising this issue and providing a solution!

This is actually a duplicate of #3513350: Hook block_class_update_20004 crashes at json_decode.

For now, let's keep this one Fixed and try making code changes in the other issue which is still open.

Thanks again for your feedback and help testing!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.