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()
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | array-offset-on-null-3527315-11.patch | 984 bytes | hmdnawaz |
Issue fork admin_toolbar-3527315
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
Comment #3
pwolanin commentedComment #4
pwolanin commentedPossibly seeing this due to installing the site in our CI from existing config.
Comment #5
dydave commentedThanks 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!
Comment #6
michael.j.gleeson commentedThis 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).
I went into config /admin/config/user-interface/admin-toolbar
saved without changing
Solved the error for me. Hope this helps.
Comment #7
pwolanin commentedYes, I think it's related to the closed issue, but I still think defensive coding is better than checking for exactly TRUE.
Comment #9
dydave commentedThanks 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!
Comment #10
dydave commentedComment #11
hmdnawaz commentedA patch file has been provided, as using a merge request as a patch poses a security risk.
Comment #12
cwyattjibc commented@michael.j.gleeson solution worked for me. I will wait for the patch to be rolled in the next release.