[BUGFIX] PHP7.2: Check value for NULL before count 42/54042/2
authorAlexander Opitz <opitz.alexander@googlemail.com>
Thu, 7 Sep 2017 07:04:47 +0000 (09:04 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 8 Sep 2017 20:31:38 +0000 (22:31 +0200)
Resolves: #82275
Releases: master, 8.7, 7.6
Change-Id: I77dc811456f4bbd759e28c27284c4652ad09dd23
Reviewed-on: https://review.typo3.org/54042
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Form/InlineStackProcessor.php

index be7cb0f..e073b40 100644 (file)
@@ -232,11 +232,11 @@ class InlineStackProcessor
     protected function calculateStructureLevel($level)
     {
         $result = false;
-        $inlineStructureCount = count($this->inlineStructure['stable']);
+        $structureCount = $this->getStructureDepth();
         if ($level < 0) {
-            $level = $inlineStructureCount + $level;
+            $level = $structureCount + $level;
         }
-        if ($level >= 0 && $level < $inlineStructureCount) {
+        if ($level >= 0 && $level < $structureCount) {
             $result = $level;
         }
         return $result;
@@ -270,6 +270,9 @@ class InlineStackProcessor
      */
     public function getStructureDepth()
     {
+        if (!isset($this->inlineStructure['stable']) || !is_array($this->inlineStructure['stable'])) {
+            return 0;
+        }
         return count($this->inlineStructure['stable']);
     }