Warning: foreach() argument must be of type array|object, null given

Created on 13 July 2023, over 1 year ago
Updated 14 July 2023, over 1 year ago

Problem/Motivation

Warning: foreach() argument must be of type array|object, null given in /app/htdocs/modules/contrib/block_class/src/Controller/BlockClassController.php on line 282

Steps to reproduce

Drupal version 10.1.1
The above error is displayed when you visit this page
admin/config/content/block-class/class-list

Proposed resolution

Move the foreach() into an if statement

if ($block_classes_stored != NULL) {
      // Get the array values and id in the keys.
      $block_classes_stored = array_values($block_classes_stored);


      foreach ($block_classes_stored as $block_class) {

        $table .= '<tr>';
        $table .= '<td>' . $block_class . '</td>';
        $table .= '</tr>';

      }
    }

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

RTBC

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom richardhobbs

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

Comments & Activities

Production build 0.71.5 2024