Warning: foreach() argument must be of type array|object on userHasSelectedRoles() AdvancedpwaController.php

Created on 12 May 2025, 3 days ago

Problem/Motivation

The error shows randomly on the Content type save and other forms.

Warning: foreach() argument must be of type array|object, null given in Drupal\advanced_pwa\Controller\AdvancedpwaController->userHasSelectedRoles() (line 319 of modules/contrib/advanced_pwa/src/Controller/AdvancedpwaController.php).
Drupal\advanced_pwa\Controller\AdvancedpwaController->userHasSelectedRoles() (Line: 290)
Drupal\advanced_pwa\Controller\AdvancedpwaController->settings()
call_user_func_array() (Line: 123)

Steps to reproduce

1. Install module.
2. Go to `/admin/config/system/advanced-pwa`.
3. Fill required fields and save the configuration.
4. Access the content types that are configured, able to see the error message.

Proposed resolution

Check variable is array before using the foreach.

Remaining tasks

Nil

User interface changes

Nil

API changes

Nil

Data model changes

Nil

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇮🇳India arunkumark Coimbatore

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