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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jessebeach’s picture

Status: Active » Needs review
FileSize
1.36 KB

This patch removes the code that produces a PHP warning.

Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community

Over 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.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

Status: Fixed » Closed (fixed)

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