Problem/Motivation
While working on #1741498: Add a mobile 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.