[BUGFIX] Prevent IconUtility to throw PHP Warning 65/28065/5
authorCaspar Stuebs <caspar@gosign.de>
Tue, 4 Mar 2014 22:16:17 +0000 (23:16 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 15 Mar 2014 21:29:24 +0000 (22:29 +0100)
Do an array typecast while using function in_array()
Clean up the code to make it more clear

Change-Id: I97738ab4bc4e1e4c346cd25836e2b4d1f875ec23
Resolves: #56558
Releases: 6.2, 6.1
Reviewed-on: https://review.typo3.org/28065
Reviewed-by: Oliver Klee
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/backend/Classes/Utility/IconUtility.php

index a52a445..2babcbb 100644 (file)
@@ -620,8 +620,12 @@ class IconUtility {
                        $innerHtml = self::getSpriteIcon($overlayIconName, $overlayOptions);
                }
 
-               // Check if requested icon is available
-               $iconName = in_array($iconName, $GLOBALS['TBE_STYLES']['spriteIconApi']['iconsAvailable']) || $iconName === 'empty-empty' ? $iconName : 'status-status-icon-missing';
+               $availableIcons = isset($GLOBALS['TBE_STYLES']['spriteIconApi']['iconsAvailable'])
+                       ? (array) $GLOBALS['TBE_STYLES']['spriteIconApi']['iconsAvailable']
+                       : array();
+               if ($iconName !== 'empty-empty' && !in_array($iconName, $availableIcons, TRUE)) {
+                       $iconName = 'status-status-icon-missing';
+               }
 
                // Create the CSS class
                $options['class'] = self::getSpriteIconClasses($iconName) . (isset($options['class']) ? ' ' . $options['class'] : '');