Undefined Array Key "intro_text" in AddToHomeScreenBlock

Created on 15 November 2023, about 1 year ago
Updated 16 November 2023, about 1 year ago

Problem/Motivation

I encountered a PHP warning related to the AddToHomeScreenBlock class in the pwa_a2hs module. The warning is triggered by an undefined array key "intro_text" in the build function of the block.

Steps to reproduce

Using twig_tweak or bamboo_twig to display the block. I'm getting the following warning:

Warning: Undefined array key "intro_text" in Drupal\pwa_a2hs\Plugin\Block\AddToHomeScreenBlock->build() (line 75 of modules/contrib/pwa/modules/pwa_a2hs/src/Plugin/Block/AddToHomeScreenBlock.php).

This warning suggests that the intro_text configuration is not set or initialized properly under certain conditions.

Expected result

The block should handle missing or uninitialized configuration gracefully, without generating PHP warnings.

Proposed resolution

A potential fix could be to ensure that the intro_text array key is checked for existence and initialized properly before being accessed in the build method.

Additional information

I am using Twig Tweak in my setup, but I believe this issue is directly related to the PHP code of the pwa_a2hs module rather than Twig Tweak.

๐Ÿ› Bug report
Status

Needs review

Version

2.1

Component

pwa_a2hs

Created by

๐Ÿ‡ฐ๐Ÿ‡ฌKyrgyzstan sahaj

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

Comments & Activities

Production build 0.71.5 2024