Since the introduction of https://www.drupal.org/node/2731369 I am getting the following error on drush site install. I get similar errors related to multiple modules (e.g. workflow, eform). I note in the other issue thread another user getting a similar problem from another module.

Notice: Undefined index: entity.eform_type.collection in admin_toolbar_tools_menu_links_discovered_alter() (line 600 of /vagrant/app/modules/contrib/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.module) #0 /vagrant/app/core/includes/bootstrap.inc(566): _drupal_error_handler_real(8, 'Undefined index...', '/vagrant/app/mo...', 600, Array)
#1 /vagrant/app/modules/contrib/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.module(600): _drupal_error_handler(8, 'Undefined index...', '/vagrant/app/mo...', 600, Array)
#2 /vagrant/app/core/lib/Drupal/Core/Extension/ModuleHandler.php(501): admin_toolbar_tools_menu_links_discovered_alter(Array, NULL, NULL)
#3 /vagrant/app/core/lib/Drupal/Core/Menu/MenuLinkManager.php(168): Drupal\Core\Extension\ModuleHandler->alter('menu_links_disc...', Array)
#4 /vagrant/app/core/lib/Drupal/Core/Menu/MenuLinkManager.php(191): Drupal\Core\Menu\MenuLinkManager->getDefinitions()
#5 /vagrant/app/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php(61): Drupal\Core\Menu\MenuLinkManager->rebuild()
#6 /vagrant/app/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php(49): Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->menuLinksRebuild()
#7 /vagrant/app/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->onRouterRebuild(Object(Symfony\Component\EventDispatcher\Event), 'routing.route_f...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#8 /vagrant/app/core/lib/Drupal/Core/Routing/RouteBuilder.php(192): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('routing.route_f...', Object(Symfony\Component\EventDispatcher\Event))
#9 /vagrant/app/core/lib/Drupal/Core/ProxyClass/Routing/RouteBuilder.php(83): Drupal\Core\Routing\RouteBuilder->rebuild()
#10 /vagrant/app/core/includes/common.inc(1141): Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild()
#11 /vagrant/app/core/includes/utility.inc(52): drupal_flush_all_caches()
#12 /vagrant/vendor/drush/drush/commands/core/cache.drush.inc(302): drupal_rebuild(Object(Composer\Autoload\ClassLoader), Object(Symfony\Component\HttpFoundation\Request))
#13 /vagrant/vendor/drush/drush/includes/command.inc(422): drush_cache_rebuild()
#14 /vagrant/vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#15 /vagrant/vendor/drush/drush/includes/command.inc(199): drush_command()
#16 /vagrant/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#17 /vagrant/vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()

Attached is a small alt that fixes the issue.

CommentFileSizeAuthor
#2 2922046-2.patch796 bytesmikejw
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikejw created an issue. See original summary.

mikejw’s picture

mikejw’s picture

Issue summary: View changes
mikejw’s picture

Issue summary: View changes
adriancid’s picture

Hi @mikejw thanks for reporting, would be great if the next time you use the Issue Summary Template to report an issue. I will check this in the next days.

adriancid’s picture

Status: Active » Postponed (maintainer needs more info)

@mikejw I'm not able to reproduce the issue with the last dev version, can you check again please?

If the issue persist please add steps to reproduce and change the issue status.

mikejw’s picture

Status: Postponed (maintainer needs more info) » Active

Ahhh, thanks for pointing me to the issue summary template - had forgotten about that.

Just tried another build with 1.x-dev and before that 1.21 and same error.

In my case this is happening on a site where the install profile includes workflow and eform and I install the site using `drush site-install`. It also throws the error after the site is installed and I do a `drush cr`.

This is on Drupal 8.4.2.

websiteworkspace’s picture

Drupal 8.4.2 - version 8.x-1.21 of this module
-----------------------------------------
Whenever clearing cache ...
The following error:


Undefined index: entity.file_type.collection in modules/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.module on line 600

is generated eight (8) times and recorded in the http error log.

This error can also be reproduced when using drupal console to clear the cache.

The function - admin_toolbar_tools_menu_links_discovered_alter(&$links) is being executed when these errors occur.

The code is iterating the following loop when the error occurs at - $parentlink = $links[$link['parent']]; - within the loop.



      // The following code is to choose the parent of the added link.
      // If the parent of the current tab also has the tab as local task
      // for example: "Content" has "File" as task" and and
      // "Content>Comment" also has "File" as a tab then we decide to
      // set this one as parent of the added link if not the current tab
      // will be the parent.
      if (!empty($link['parent'])) {
        $parentlink = $links[$link['parent']];
        $parentlink_route = $parentlink['route_name'];
        $parent_primary = $manager->getLocalTasks($parentlink_route, 0);
        foreach ($parent_primary['tabs'] as $parent_tab) {
          if ($parent_tab['#link']['url']) {
            $parent_route = $parent_tab['#link']['url']->getRouteName();
            if ($parent_route == $local_route) {
              $parent = $link['parent'];
              break;
            }
          }
        }
      }


adriancid’s picture

@mikejw and @websiteworkspace check if #2925327: Better check for is-link-in-admin-menu for local task links solve the problem.

websiteworkspace’s picture

There is more than one patch listed at the following link:

https://www.drupal.org/project/admin_toolbar/issues/2925327

Which if any of these patches are you recommending?

Both seem to insert a new section of code at around line 539.
However, it seems like a prudent coder would add some additional integrity checking at line 600 itself

$parentlink = $links[$link['parent']];

to further guard against the empty array index problem at that location, providing additional "sanity" checking of the referenced data.

adriancid’s picture

Berdir’s picture

Status: Active » Needs review

No, #2925327: Better check for is-link-in-admin-menu for local task links is about a different problem and not related.

The fix makes sense to me and is similar to #2873577: Do not define menu links for entity bundles when the parent is not defined. that I once opened, but this is a bit more generic.

adriancid’s picture

Thanks @Berdir, if you're able to reproduce the issue can you test the patch to see if it works?

BrianLewisDesign’s picture

Patch 2 from #2 works for me.

  • adriancid committed 0f0ae25 on 8.x-1.x authored by mikejw
    Issue #2922046 by mikejw, adriancid, Berdir, BrianLewisDesign: Notice:...
adriancid’s picture

Status: Needs review » Fixed

Thanks to @all :-)

mikejw’s picture

Thanks!

Status: Fixed » Closed (fixed)

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

websiteworkspace’s picture

This bug should not be marked as "fixed" since there still isn't a release version of this module that includes the patch that repairs the reported problem.