Problem/Motivation

After upgrading to PHP 7.4, I'm seeing a lot of these notices in our logs:

Notice: Trying to access array offset on value of type bool in commerce_kickstart_taxonomy_preprocess_page() (line 10 of /code/profiles/commerce_kickstart/modules/commerce_kickstart/commerce_kickstart_taxonomy/commerce_kickstart_taxonomy.module).

Proposed resolution

Looks like a very similar issue to this one: https://www.drupal.org/project/commerce_kickstart/issues/3241668

To clear this up, we could check if $router_item is FALSE before trying to access array values.

Comments

hey_germano created an issue. See original summary.

hey_germano’s picture

StatusFileSize
new888 bytes

Here's a patch.

rszrama’s picture

Version: 7.x-2.71 » 7.x-2.x-dev
Status: Active » Reviewed & tested by the community
StatusFileSize
new890 bytes

Thanks, I noticed these, too, but didn't have a minute to track it down! I'm going to follow a different pattern on commit, using a !empty() check on the array offset itself. This will work whether the variable is an array or if it's just missing that index.

  • rszrama committed 8ebde83 on 7.x-2.x
    Issue #3266601 by hey_germano, rszrama: Notice: Trying to access array...
rszrama’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.