Problem/Motivation

Since updating to 3.6.0 we are seeing this in the logs:

 │              [%type] => Warning
  │              [@message] => __PHP_Incomplete_Class Object
  │                  (
  │                      [__PHP_Incomplete_Class_Name] => Drupal\Core\Render\Markup
  │                      [string:protected] => Trying to access array offset on value of type null
  │                  )
  │  
  │              [%function] => admin_toolbar_toolbar_alter()
  │              [%file] => /var/www/drupal/web/modules/drupal/admin_toolbar/admin_toolbar.module
                  [%line] => 39

That's a little funny since I see that key is in the install config, but the code could easily be more defensive and use an empty() check instead of checking exactly for TRUE.

Proposed resolution

Use empty()

CommentFileSizeAuthor
#11 array-offset-on-null-3527315-11.patch984 byteshmdnawaz
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pwolanin created an issue. See original summary.

pwolanin’s picture

Status: Active » Needs review
pwolanin’s picture

Possibly seeing this due to installing the site in our CI from existing config.

dydave’s picture

Thanks Peter (@pwolanin)!

Any chance this could be related to #3525987: Warning: Trying to access array offset on null in admin_toolbar_toolbar_alter()?

Thanks in advance!

michael.j.gleeson’s picture

This might help.

Got this on my Local,
Warning: Trying to access array offset on null in admin_toolbar_toolbar_alter() (line 39 of modules/contrib/admin_toolbar/admin_toolbar.module).

$ddev drush config:get admin_toolbar.settings
menu_depth: 4

I went into config /admin/config/user-interface/admin-toolbar
saved without changing

ddev drush config: get admin_toolbar.settings
enable_toggle_shortcut: false
menu_depth: 4
sticky_behavior: enabled
hoverintent_behavior:
  enabled: true
  timeout: 250

Solved the error for me. Hope this helps.

pwolanin’s picture

Yes, I think it's related to the closed issue, but I still think defensive coding is better than checking for exactly TRUE.

  • dydave committed cad39ffe on 3.x authored by pwolanin
    Issue #3527315 by pwolanin: Use defensive coding to prevent warning '...
dydave’s picture

Status: Needs review » Fixed

Thanks a lot Peter (@pwolanin) for taking the time to look at this and give us some advice.

When we first encountered this issue in #3440852-26: Make un-hover delay configurable, I suggested to @ressa to test with the update hook, which fixed it, but we didn't anticipate on other types of issues.

We will try to stick to this approach in the future if there are more configuration changes with update hooks, to avoid as much as possible these types of issues.

For the time being, I went ahead and merged the changes above at #8.

This will most likely be released as a patch release, along with several other issues, if possible, in a 3.6.1 corrective version, for example.

Marking issue as Fixed for now.

Feel free to let us know if you spot anything else or if we missed anything, we would certainly be glad to help.
Thanks in advance!

hmdnawaz’s picture

StatusFileSize
new984 bytes

A patch file has been provided, as using a merge request as a patch poses a security risk.

cwyattjibc’s picture

@michael.j.gleeson solution worked for me. I will wait for the patch to be rolled in the next release.

Status: Fixed » Closed (fixed)

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