Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
PHP 7.4 produce notices when trying to access nonexistent array index. Those are displayed in Drupal DBlog:
"Notice: Trying to access array offset on value of type null..."
Steps to reproduce
Use Block Styles module with PHP 7.4
Proposed resolution
Check if array index is set before evaluating it.
Comment | File | Size | Author |
---|---|---|---|
#5 | 3168455-5.patch | 1.06 KB | t_d_d |
Comments
Comment #2
t_d_d CreditAttribution: t_d_d commentedpatch with fix provided
Comment #3
arx-e CreditAttribution: arx-e commentedIsn't the second evaluation redundant?
Wouldn't it be simpler to leave just the isset evaluation alone like this?
if ( isset($style['theme']) ) {
instead of this
if (isset($style['theme']) && $style['theme']) {
Comment #4
t_d_d CreditAttribution: t_d_d commentedI dont know if it is possible to have empty string there and if that would be a problem for theming, but i guess not. I just left second evaluation there to be sure not to change original behavior.
Comment #5
t_d_d CreditAttribution: t_d_d commentedOk, looks like only falsy thing ("0") that second condition will prevent is already prevented somewhere else so second conditon is most likely really redundant. New patch attached.
Comment #6
hatuhay CreditAttribution: hatuhay commented