Error Instantiating BlockContentPseudoEntity - TypeError: Argument #3 ($info) must be of type string, null given

Created on 22 October 2024, about 1 month ago

Problem/Motivation

Getting the following error when installing module and navigating to Block Usage Report page:

TypeError: Drupal\block_usage_report\BlockContentPseudoEntity::__construct(): Argument #3 ($info) must be of type string, null given, called in /var/www/html/web/modules/contrib/block_usage_report/src/BlockContentPseudoEntity.php on line 47 in Drupal\block_usage_report\BlockContentPseudoEntity->__construct() (line 24 of modules/contrib/block_usage_report/src/BlockContentPseudoEntity.php).

Steps to reproduce

Install and enable Block Usage Report module
Navigate to /admin/reports/block-usage

Proposed resolution

A possible solution would be to add a check to ensure that $info is never null. Here's an example of how this can be done:

foreach ($result as $row) {
  $info = $row->info ?? ''; // Check if info is null and set to an empty string if it is.
  $blocks[] = new static(
    $row->uuid,
    $row->type,
    $info,
    $row->id
  );
}

Additional Context

Drupal core: 10.3.5
PHP: 8.2.15

๐Ÿ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

๐Ÿ‡ต๐Ÿ‡นPortugal developer-rocha

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024