Prevent PHP Warnings by Ensuring Node Bundle Existence Before Iteration

Created on 18 May 2024, about 1 month ago

Problem/Motivation

When installing the BEE module in a Drupal instance without any defined node types, the system throws multiple PHP warnings related to undefined array keys and invalid arguments for foreach. This issue occurs because the module assumes the presence of node types without checking if they exist.

Warning: Undefined array key β€œnode” in Drupal\bee\BeePermissions->permissions() (line 62 of modules/contrib/bee/src/BeePermissions.php).
Warning: foreach() argument must be of type array|object, null given in Drupal\bee\BeePermissions->permissions() (line 62 of modules/contrib/bee/src/BeePermissions.php).

These warnings repeat multiple times and are triggered during the permissions setup by the module.

Steps to reproduce

  1. Ensure no node types are defined in the Drupal system.
  2. Install the BEE module.
  3. Access any page that triggers the permissions setup in BEE.

Proposed resolution

Implement a conditional check within the permissions() method to verify the presence of node types before processing them. This will prevent the system from attempting to process an undefined or null data structure.

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany Majdi

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024