Undefined array key "#active" in Drupal\admin_toolbar_tools\AdminToolbarToolsHelper->buildLocalTasksToolbar()

Created on 30 October 2023, 8 months ago
Updated 9 April 2024, 3 months ago

Problem/Motivation

Getting error

Warning: Undefined array key "#active" in Drupal\admin_toolbar_tools\AdminToolbarToolsHelper->buildLocalTasksToolbar() (line 100 of modules/contrib/admin_toolbar/admin_toolbar_tools/src/AdminToolbarToolsHelper.php).

When local tasks are enabled in the toolbar

Steps to reproduce

Enable local tasks in the settings
view a node.
I see this error.

Turn off local tasks, and the error goes away.

๐Ÿ› Bug report
Status

Needs review

Version

3.4

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States loze

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @loze
  • Assigned to Mohd Sahzad
  • Issue was unassigned.
  • Status changed to Needs review 8 months ago
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 8
    last update 8 months ago
    Waiting for branch to pass
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Mohd Sahzad

    I have updated this issue in attached patch1, please review

  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 8
    last update 8 months ago
    Waiting for branch to pass
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom hdotnet

    Mohd's patch almost worked...

    Added an is_array check prior to array_key_exists..

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States Dave Reid Nebraska ๐Ÿ‡บ๐Ÿ‡ธ

    Can you provide more details on how to replicate this? I have yet to see this error on any of my sites.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia MukhtarM

    I am too not geting this reproduced in local. In fact i wonder when i enable Enable/Disable local tasks display what are the changes would effect? As node edit and delete already there. (may somebody point here would help)

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom hdotnet

    I was doing too much at the time to properly trace why the error was happening so Iโ€™m afraid this will be hard to replicate. Iโ€™m working with a very old site (all be it up
    to date) and there is a lot going on in local tasks.

    In general, I would say the if statement as it stands isnโ€™t doing enough to ensure the integrity of the array. I guess this is why we are here?

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Sandeep_k New Delhi

    Hi, We need more details here, I have tested this on Drupal- 10.2 versions & unable to reproduce this.

  • ๐Ÿ‡ท๐Ÿ‡ธSerbia vaish

    I run into this after installing content_entity_clone module on a site where admin_toolbar_tools is enabled and "Enable/Disable local tasks display" setting is turned on. Content entity clone uses hook_menu_local_tasks_alter() to create new local task but it doesn't define #active key. Fix is included in the MR for โœจ Admin content add link in operation Needs review . Unfortunately, I had trouble reproducing the issue. I'm getting it on a project with many contrib and custom modules but not on the clean Drupal install. Judging by the previous comments, issue is extremely rare but it may happen under very specific circumstances.

Production build 0.69.0 2024