[BUGFIX] Test ifBlank with strlen again 05/56305/3
authorStefan Froemken <froemken@gmail.com>
Sat, 17 Mar 2018 13:58:28 +0000 (14:58 +0100)
committerAndreas Wolf <andreas.wolf@typo3.org>
Sat, 17 Mar 2018 15:52:00 +0000 (16:52 +0100)
Since TYPO3 7 ifBlank works with trim instead of strlen.
Like documented ifBlank has to work with strlen.
So 2 spaces should not be interpreted as a blank value.

Resolves: #84434
Related: #54091
Releases: master, 8.7
Change-Id: I6a130852225b23f30af40e8a9311d2288dfb31b6
Reviewed-on: https://review.typo3.org/56305
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Andreas Wolf <andreas.wolf@typo3.org>
Tested-by: Andreas Wolf <andreas.wolf@typo3.org>
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php

index 3253296..c0c25bb 100644 (file)
@@ -1906,7 +1906,7 @@ class ContentObjectRenderer
      */
     public function stdWrap_ifBlank($content = '', $conf = [])
     {
-        if (trim($content) === '') {
+        if (strlen($content) === 0) {
             $content = $conf['ifBlank'];
         }
         return $content;
index f5e5385..22c95b4 100644 (file)
@@ -5578,13 +5578,13 @@ class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTe
             'null is blank' => [$alt, null, $conf],
             'false is blank' => [$alt, false, $conf],
             'empty string is blank' => [$alt, '', $conf],
-            'whitespace is blank' => [$alt, TAB . '', $conf],
             // non-blank cases
             'string is not blank' => ['string', 'string', $conf],
             'zero is not blank' => [0, 0, $conf],
             'zero string is not blank' => ['0', '0', $conf],
             'zero float is not blank' => [0.0, 0.0, $conf],
             'true is not blank' => [true, true, $conf],
+            'whitespace is not blank' => ['  ', '  ', $conf],
         ];
     }