From 6f4ab27577690b003498818c77ae2ac2d4f34e46 Mon Sep 17 00:00:00 2001
From: Richard Haeser <richard@maxserv.com>
Date: Fri, 5 Jan 2018 11:44:01 +0100
Subject: [PATCH] [BUGFIX] Make empty $GLOBALS['TBE_MODULES_EXT'] traversable

Prevent warnings and notices if $GLOBALS['TBE_MODULES_EXT'] is not
set, which can be the case if no extensions are installed.

Change-Id: I72f513329790ee3b71fd30054574b79f41a6dcf8
Resolves: #83479
Releases: master, 8.7, 7.6
Reviewed-on: https://review.typo3.org/55297
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Richard Haeser <richard@maxserv.com>
Tested-by: Richard Haeser <richard@maxserv.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../Module/BackendModuleRepository.php        | 34 ++++++++++---------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Domain/Repository/Module/BackendModuleRepository.php b/typo3/sysext/backend/Classes/Domain/Repository/Module/BackendModuleRepository.php
index ea0a4d5b6542..e697458f806a 100644
--- a/typo3/sysext/backend/Classes/Domain/Repository/Module/BackendModuleRepository.php
+++ b/typo3/sysext/backend/Classes/Domain/Repository/Module/BackendModuleRepository.php
@@ -191,23 +191,25 @@ class BackendModuleRepository implements \TYPO3\CMS\Core\SingletonInterface
      */
     protected function createMenuEntriesForTbeModulesExt()
     {
-        foreach ($GLOBALS['TBE_MODULES_EXT'] as $mainModule => $tbeModuleExt) {
-            list($main) = explode('_', $mainModule);
-            $mainEntry = $this->findByModuleName($main);
-            if ($mainEntry === false) {
-                continue;
-            }
+        if (isset($GLOBALS['TBE_MODULES_EXT'])) {
+            foreach ((array)$GLOBALS['TBE_MODULES_EXT'] as $mainModule => $tbeModuleExt) {
+                list($main) = explode('_', $mainModule);
+                $mainEntry = $this->findByModuleName($main);
+                if ($mainEntry === false) {
+                    continue;
+                }
 
-            $subEntries = $mainEntry->getChildren();
-            if (empty($subEntries)) {
-                continue;
-            }
-            $matchingSubEntry = $this->findByModuleName($mainModule);
-            if ($matchingSubEntry !== false) {
-                if (isset($tbeModuleExt['MOD_MENU']) && isset($tbeModuleExt['MOD_MENU']['function'])) {
-                    foreach ($tbeModuleExt['MOD_MENU']['function'] as $subModule) {
-                        $entry = $this->createEntryFromRawData($subModule);
-                        $matchingSubEntry->addChild($entry);
+                $subEntries = $mainEntry->getChildren();
+                if (empty($subEntries)) {
+                    continue;
+                }
+                $matchingSubEntry = $this->findByModuleName($mainModule);
+                if ($matchingSubEntry !== false) {
+                    if (isset($tbeModuleExt['MOD_MENU']) && isset($tbeModuleExt['MOD_MENU']['function'])) {
+                        foreach ($tbeModuleExt['MOD_MENU']['function'] as $subModule) {
+                            $entry = $this->createEntryFromRawData($subModule);
+                            $matchingSubEntry->addChild($entry);
+                        }
                     }
                 }
             }
-- 
GitLab