[BUGFIX] IconFactory check arrays for key 17/51217/2
authorAlexander Opitz <opitz.alexander@googlemail.com>
Thu, 15 Dec 2016 10:47:25 +0000 (11:47 +0100)
committerAlexander Opitz <opitz.alexander@googlemail.com>
Mon, 9 Jan 2017 17:10:13 +0000 (18:10 +0100)
This reduces PHP notices, as we check arrays before acessing them.

Resolves: #78992
Releases: master, 7.6
Change-Id: Ib0fc72be9e7957a27990d60dde844068ca9e24d1
Reviewed-on: https://review.typo3.org/51217
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
typo3/sysext/core/Classes/Imaging/IconFactory.php

index 2ded22f..d1b9059 100644 (file)
@@ -195,7 +195,9 @@ class IconFactory
                     }
                 }
             }
-            if (is_array($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'])) {
+            if (isset($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'])
+                && is_array($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'])
+            ) {
                 foreach ($recordType as $key => $type) {
                     if (isset($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'][$type])) {
                         $recordType[$key] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'][$type];
@@ -226,7 +228,9 @@ class IconFactory
                 unset($type);
                 $recordType[0] = 'tcarecords-' . $table . '-default';
             }
-        } elseif (is_array($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'])) {
+        } elseif (isset($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'])
+            && is_array($GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'])
+        ) {
             $recordType[0] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_classes']['default'];
         } else {
             $recordType[0] = 'tcarecords-' . $table . '-default';
@@ -263,10 +267,10 @@ class IconFactory
             'fe_group' => false,
             'deleted' => false,
             'protectedSection' => false,
-            'nav_hide' => (bool)$row['nav_hide']
+            'nav_hide' => !empty($row['nav_hide']),
         ];
         // Icon state based on "enableFields":
-        if (is_array($tcaCtrl['enablecolumns'])) {
+        if (isset($tcaCtrl['enablecolumns']) && is_array($tcaCtrl['enablecolumns'])) {
             $enableColumns = $tcaCtrl['enablecolumns'];
             // If "hidden" is enabled:
             if (isset($enableColumns['disabled']) && !empty($row[$enableColumns['disabled']])) {