Project

General

Profile

Actions

Bug #86969

closed

stdWrap ifEmpty/ifNull/ifBlank are evaluated even if content is there

Added by Wolfgang Klinger over 5 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
TypoScript
Target version:
-
Start date:
2018-11-21
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Take this as example (and imagine some heavy processing behind the COA object in ifEmpty):

page = PAGE
page.10 = TEXT
page.10.value = Hello world!
page.10.ifEmpty = TEXT
page.10.ifEmpty {
  cObject = COA
  cObject.1 = TEXT
  cObject.1.value = I should never 
  cObject.2 = TEXT
  cObject.2.value = be seen
}

The whole COA is processed and then discarded useless.


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #90318: stdWrap.ifEmpty not called anymore on potentially empty stringsClosed2020-02-04

Actions
Related to TYPO3 Core - Bug #90908: Zeros are not treated as empty values in `.ifEmpty`Closed2020-03-31

Actions
Actions #1

Updated by Gerrit Code Review over 5 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58928

Actions #2

Updated by Riccardo De Contardi over 5 years ago

  • Category set to TypoScript
Actions #3

Updated by Gerrit Code Review over 5 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58928

Actions #4

Updated by Gerrit Code Review over 4 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/58928

Actions #5

Updated by Gerrit Code Review over 4 years ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62142

Actions #6

Updated by Wolfgang Klinger over 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #7

Updated by Benni Mack over 4 years ago

  • Status changed from Resolved to Closed
Actions #8

Updated by Francois Suter about 4 years ago

I understand the idea but the implementation is wrong for the "ifEmpty" function. 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 #9

Updated by Francois Suter about 4 years ago

  • Related to Bug #90318: stdWrap.ifEmpty not called anymore on potentially empty strings added
Actions #10

Updated by Francois Suter about 4 years ago

I opened a specific bug report: https://forge.typo3.org/issues/90318

Actions #11

Updated by Sascha Egerer about 4 years ago

  • Related to Bug #90908: Zeros are not treated as empty values in `.ifEmpty` added
Actions

Also available in: Atom PDF