[BUGFIX] Handle empty string icon-overlay identifier 12/54212/4
authorRomain Canon <romain.hydrocanon@gmail.com>
Sat, 23 Sep 2017 13:07:02 +0000 (15:07 +0200)
committerFrank Naegler <frank.naegler@typo3.org>
Fri, 29 Sep 2017 15:43:27 +0000 (17:43 +0200)
An overlay identifier can be an empty string, for instance when the icon API is
called with the Fluid icon view helper:

```
<core:icon identifier="tx-my-icon"
           overlay="{f:if(condition: myCondition, then: 'my-overlay-icon')}" />
```

In the example below, if the condition `myCondition` is `false`, an empty string
is used for the overlay parameter.

---

Previously, an empty string as overlay identifier would lead to the basic "not
found icon" being used as overlay.

With this commit, the behaviour for an empty string will now be the same as when
 `null` is used.

---

Resolves: #82547
Releases: master, 8.7
Change-Id: I6fb8207f302873e0188d71a210485bbf8565eff9
Reviewed-on: https://review.typo3.org/54212
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Romain Canon <romain.hydrocanon@gmail.com>
Tested-by: Romain Canon <romain.hydrocanon@gmail.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/core/Classes/Imaging/IconFactory.php

index 0cdbea3..4b9994b 100644 (file)
@@ -138,9 +138,6 @@ class IconFactory
     {
         $iconIdentifier = $this->mapRecordTypeToIconIdentifier($table, $row);
         $overlayIdentifier = $this->mapRecordTypeToOverlayIdentifier($table, $row);
-        if (empty($overlayIdentifier)) {
-            $overlayIdentifier = null;
-        }
         return $this->getIcon($iconIdentifier, $size, $overlayIdentifier);
     }
 
@@ -475,7 +472,7 @@ class IconFactory
         $icon->setIdentifier($identifier);
         $icon->setSize($size);
         $icon->setState($iconConfiguration['state'] ?: new IconState());
-        if ($overlayIdentifier !== null) {
+        if (!empty($overlayIdentifier)) {
             $icon->setOverlayIcon($this->getIcon($overlayIdentifier, Icon::SIZE_OVERLAY));
         }
         if (!empty($iconConfiguration['options']['spinning'])) {