Problem/Motivation
While working on #1741498: Add a responsive preview bar to Drupal core, I noticed that passing a custom render array to toolbar for a tab raised the following warning:
Notice: Undefined index: #options in toolbar_pre_render_item() (line 291 of core/modules/toolbar/toolbar.module).
This warning is created by the following code in toolbar_pre_render_item
// Attributes are nested in the #options property passed to l().
// To make the return structure of toolbar_pre_render_item() uniform,
// attributes will always be returned in the #attributes property. These
// properties will be included in the #options parameter passed to l() in
// theme_toolbar_tab().
$element['#attributes'] = $element['tab']['#options']['attributes'];
This code is left over from the original hook_toolbar
implementation that expected a tab to be structured like a link
. Now that #1847198: Update the structure returned by hook_toolbar() is committed, we can remove the vestigial code.
Proposed resolution
Remove the unused code that is throwing a warning.
Comment | File | Size | Author |
---|---|---|---|
#1 | toolbar-prerender-warning_1908906-1.patch | 1.36 KB | jessebeach |
Comments
Comment #1
jessebeach CreditAttribution: jessebeach commentedThis patch removes the code that produces a PHP warning.
Comment #2
Wim LeersOver at #1874664: Introduce toolbar level "Edit" mode that shows all contextual links we also have to add extra code to work around this.
Straightforward code removal.
Comment #3
catchCommitted/pushed to 8.x, thanks!