From 76b645b7851aa5d1ae29cf4c9bb9b7bd48f92250 Mon Sep 17 00:00:00 2001
From: Thomas Hohn <thomas@hohn.dk>
Date: Mon, 23 Jan 2017 13:08:34 +0100
Subject: [PATCH] [BUGFIX] Fix runtime-error in traverseFlexFormXMLData

Fix that run-time error will be thrown if
$dataStructureArray['sheets'] is not an array.

Fixes: #79426
Releases: master
Change-Id: I9b7549a5b79d0d5b8b2e27df407879812c1aa491
Reviewed-on: https://review.typo3.org/51399
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
---
 .../core/Classes/Configuration/FlexForm/FlexFormTools.php     | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/typo3/sysext/core/Classes/Configuration/FlexForm/FlexFormTools.php b/typo3/sysext/core/Classes/Configuration/FlexForm/FlexFormTools.php
index 88056cf7973a..1399622c1455 100644
--- a/typo3/sysext/core/Classes/Configuration/FlexForm/FlexFormTools.php
+++ b/typo3/sysext/core/Classes/Configuration/FlexForm/FlexFormTools.php
@@ -777,6 +777,10 @@ class FlexFormTools
         if (!is_array($editData)) {
             return 'Parsing error: ' . $editData;
         }
+        // Check if $dataStructureArray['sheets'] is indeed an array before loop or it will crash with runtime error
+        if (!is_array($dataStructureArray['sheets'])) {
+            return 'Data Structure ERROR: sheets is defined but not an array for table ' . $table . (isset($row['uid']) ? ' and uid ' . $row['uid'] : '');
+        }
         // Traverse languages:
         foreach ($dataStructureArray['sheets'] as $sheetKey => $sheetData) {
             // Render sheet:
-- 
GitLab