From 80d93c92cf83c6ef4f01791da6618f10478cff4a Mon Sep 17 00:00:00 2001
From: William Hearn <sylus1984@gmail.com>
Date: Tue, 14 Nov 2017 21:18:17 -0500
Subject: [PATCH] Issue #2923580: Unexpected operand + restricted permissions +
 reference to admin_toolbar_tools.flush

---
 admin_toolbar_tools/src/ToolbarHandler.php | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/admin_toolbar_tools/src/ToolbarHandler.php b/admin_toolbar_tools/src/ToolbarHandler.php
index 6f513af..58a548b 100644
--- a/admin_toolbar_tools/src/ToolbarHandler.php
+++ b/admin_toolbar_tools/src/ToolbarHandler.php
@@ -62,16 +62,18 @@ class ToolbarHandler implements ContainerInjectionInterface {
     $this->arrayInsert($tools_menu, 1, $menu_render_array);
 
     // Adding the submenus to 'Flush all caches' menu.
-    $tools_sub_menu = &$tools_menu['admin_toolbar_tools.flush']['below'];
-    $tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.cssjs', $this->t('Flush CSS and Javascript'));
-    $tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.plugin', $this->t('Flush plugins cache'));
-    $tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.flush_static', $this->t('Flush static cache'));
-    $tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.flush_menu', $this->t('Flush routing and links  cache'));
-    $tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.flush_rendercache', $this->t('Flush render cache'));
-
-    // Adding a menu link to clean the Views cache.
-    if ($this->moduleHandler->moduleExists('views')) {
-      $tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.flush_views', $this->t('Flush views cache'));
+    if (!empty($tools_menu['admin_toolbar_tools.flush'])) {
+      $tools_sub_menu = &$tools_menu['admin_toolbar_tools.flush']['below'];
+      $tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.cssjs', $this->t('Flush CSS and Javascript'));
+      $tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.plugin', $this->t('Flush plugins cache'));
+      $tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.flush_static', $this->t('Flush static cache'));
+      $tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.flush_menu', $this->t('Flush routing and links  cache'));
+      $tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.flush_rendercache', $this->t('Flush render cache'));
+
+      // Adding a menu link to clean the Views cache.
+      if ($this->moduleHandler->moduleExists('views')) {
+        $tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.flush_views', $this->t('Flush views cache'));
+      }
     }
 
     // Adding the 'Run Cron' menu in the correct place.
-- 
2.5.4 (Apple Git-61)

