Actions
Bug #90318
closedstdWrap.ifEmpty not called anymore on potentially empty strings
Start date:
2020-02-04
Due date:
% Done:
100%
Estimated time:
TYPO3 Version:
9
PHP Version:
7.3
Tags:
Complexity:
easy
Is Regression:
Yes
Sprint Focus:
Description
In https://review.typo3.org/c/Packages/TYPO3.CMS/+/58928 an optimization was introduced to avoid calling "ifEmpty" or "ifBlank" if the content is not empty. However this is wrongly evaluated for "ifEmpty".
Indeed "ifEmpty" bases itself on the PHP function "trim" which considers:
" " (ASCII 32 (0x20)), an ordinary space.
"\t" (ASCII 9 (0x09)), a tab.
"\n" (ASCII 10 (0x0A)), a new line (line feed).
"\r" (ASCII 13 (0x0D)), a carriage return.
"\0" (ASCII 0 (0x00)), the NUL-byte.
"\x0B" (ASCII 11 (0x0B)), a vertical tab.
as empty characters. But the check that was introduced about whether to call "ifEmpty" or not checks emptiness with the "empty" PHP function which considers:
"" (an empty string)
0 (0 as an integer)
0.0 (0 as a float)
"0" (0 as a string)
NULL
FALSE
array() (an empty array)
as empty elements. This is very different from "trim" (excerpts taken from the PHP manual).
I would say the proper check should be:
$functionName === 'ifEmpty' && trim($content) !== ''
Actions