ForEach Call on NULL

Created on 7 December 2022, over 1 year ago
Updated 20 January 2023, over 1 year ago

Problem/Motivation

We are seeing the following PHP warning in watchdog:

Warning: foreach() argument must be of type array|object, null given in Drupal\webformnavigation\Plugin\WebformHandler\WebformNavigationHandler->alterForm() (line 120 of /modules/contrib/webformnavigation/src/Plugin/WebformHandler/WebformNavigationHandler.php) 

Currently, we are seeing this on PHP 8.0 but also saw it on PHP 7.4.

Steps to reproduce

I'm not entirely sure when it happens but I believe it is when users are either on a confirmation page or when there are not any pages in the form state.

Proposed resolution

Either get the pages from the Webform Entity or ensure the page array is not null before passing them into the forEach.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States rymcveigh

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024