Review main Merged

64029[BUGFIX] Revert behaviour of stdWrap ifEmpty

Sascha Egerer CR +2 V +2 Easy +45 −4 updated 01/20/22, 19:16

Commit message

The stdWrap function ifEmpty must return true if a
PHP falsy value is given. That means e.g. an empty
string or a "0".

To make it more clear that stdWrap ifEmpty in fact
uses the logic of the PHP function "empty", this
function is now used.

First, the value is trimmed, which means a string
is returned, and then this value is passed to the
empty function.

As this works now properly, the getCurrentValue
method needed a check against empty array keys. The
stdWrap_current method now uses the getCurrentValue
method as they both do the exact same thing.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Oli Bartsch +1
    • Stefan Bürk +1
    • Nikita Hovratov +1
  • Verified V +2 Done
    • Benni Mack +2
    • Oli Bartsch +1
    • Stefan Bürk +1
    • Nikita Hovratov +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 3750

Show 1825 earlier messages
  1. Sascha Egerer uploaded patch set 1 03/31/20, 11:43

  2. TYPO3com voted on patch set 1 V -1 03/31/20, 11:56 Completed build in 12m 24s on Tue, 31 Mar, 11:56 AM Test Summary: 36 of 73537 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2021

  3. Mathias Brodala commented on patch set 1 03/31/20, 12:07

    Can we have a test which ensures this works as indentend and is never broken again?
  4. Sascha Egerer uploaded patch set 2 03/31/20, 12:51

  5. TYPO3com voted on patch set 2 V -1 03/31/20, 13:03 Completed build in 11m 53s on Tue, 31 Mar, 01:03 PM Test Summary: 7 of 73560 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2026

  6. Mathias Brodala commented on patch set 2 03/31/20, 13:27

    ContentObjectRendererTest.php:1274

    I think we should stick to the output and not test any internal details like this.
  7. Sascha Egerer commented on patch set 2 03/31/20, 13:35

    ContentObjectRendererTest.php:1274 Reply

    You mean the output of stdWrap? I think the output depends on to many other stuff which could influence the result so i would go this way for this case. But other feedback is very welcome.
  8. Mathias Brodala commented on patch set 2 03/31/20, 13:44

    ContentObjectRendererTest.php:1274 Reply

    OK, it seems I misunderstood "content" here as the output whereas it is actually the input. Still you should be able to define a full TEXT object and execute the real stdWrap function ...
  9. TYPO3com commented on patch set 2 03/31/20, 13:50 Completed build in 1h 10m 27s on Tue, 31 Mar, 01:50 PM Test Summary: 6 of 73561 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2026

  10. Sascha Egerer commented on patch set 2 03/31/20, 13:53

    ContentObjectRendererTest.php:1274 Reply

    And then also check the result of stdWrap? As said i think we should not test the result here as this will already be checked at other places. This tests only checks if the ifEmpty function is called at all due to an additional pre execution check. I'm fine width adding a 'value' to the TEXT object but this does not really change anything for this test.
  11. TYPO3com voted on patch set 2 V +1 03/31/20, 17:08 Completed build in 5h 26m 45s on Tue, 31 Mar, 05:08 PM Test Summary: 73074 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2026

  12. TYPO3com voted on patch set 1 V +1 03/31/20, 17:20 Completed build in 5h 48m 52s on Tue, 31 Mar, 05:20 PM Test Summary: 73050 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-2021

  13. Susi Moog commented on patch set 2 04/01/20, 05:35

    It would make sense to test the combination of pre-condition and later execution of ifEmpty to make sure that "unit" works - if you look at the history and the previous patches we try to get it right suprisingly often - for such a little function. And the original bugfix in this case was a mismatch between the pre-check and the execution.
  14. Sascha Egerer commented on patch set 2 04/01/20, 19:08

    > Patch Set 2: > > It would make sense to test the combination of pre-condition and later execution of ifEmpty to make sure that "unit" works - if you look at the history and the previous patches we try to get it right suprisingly often - for such a little function. And the original bugfix in this case was a mismatch between the pre-check and the execution. But this is what i did in the current test, right? I do check if the condition behaves as expected and ifEmpty is called as expected. There are already unit tests for stdWrap_ifEmpty so there is no need the test the result again, right?
  15. Susi Moog commented on patch set 2 04/21/20, 12:10

    > Patch Set 2: > > > Patch Set 2: > > > > It would make sense to test the combination of pre-condition and later execution of ifEmpty to make sure that "unit" works - if you look at the history and the previous patches we try to get it right suprisingly often - for such a little function. And the original bugfix in this case was a mismatch between the pre-check and the execution. > > But this is what i did in the current test, right? I do check if the condition behaves as expected and ifEmpty is called as expected. There are already unit tests for stdWrap_ifEmpty so there is no need the test the result again, right? Sry for not getting back to you yet, what I meant is: do we now have a test that fails and shows the original bug that was fixed / bugfixed in the last patch to make sure that does not happen again?
  16. Sascha Egerer commented on patch set 2 04/21/20, 12:27

    > Patch Set 2: > > > Patch Set 2: > > > > > Patch Set 2: > > > > > > It would make sense to test the combination of pre-condition and later execution of ifEmpty to make sure that "unit" works - if you look at the history and the previous patches we try to get it right suprisingly often - for such a little function. And the original bugfix in this case was a mismatch between the pre-check and the execution. > > > > But this is what i did in the current test, right? I do check if the condition behaves as expected and ifEmpty is called as expected. There are already unit tests for stdWrap_ifEmpty so there is no need the test the result again, right? > > Sry for not getting back to you yet, what I meant is: do we now have a test that fails and shows the original bug that was fixed / bugfixed in the last patch to make sure that does not happen again? That should be validated by the tests I've added.
  17. Benni Mack updated the commit message in patch set 3 05/25/20, 18:48

  18. Marc Bastian Heinrichs commented on patch set 3 V +1 05/20/21, 16:00

    Patch works like expected, but from reading I don't like bool casting. I suggest to add a extra constraint !== '0'
  19. Benni Mack commented on patch set 3 11/05/21, 11:23

    Hey Sascha, can you rebase the patch?
  20. Nikita Hovratov uploaded patch set 4 11/16/21, 17:53

  21. Nikita Hovratov commented on patch set 4 11/16/21, 17:54

    Reply

    done.
  22. core-ci voted on patch set 4 V -1 11/16/21, 17:58 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19366

  23. Stefan Bürk commented on patch set 5 11/16/21, 18:03

    Published edit on patch set 4.
  24. core-ci voted on patch set 5 V +1 11/16/21, 18:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19367

  25. Sascha Egerer commented on patch set 5 11/16/21, 19:04

    Thank you Nikita for taking care
  1. Benni Mack updated the commit message in patch set 6 11/18/21, 10:48

  2. core-ci voted on patch set 6 V +1 11/18/21, 12:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/19476

  3. Benni Mack wrote 11/28/21, 22:06

    Removed cc Benni Mack.
  4. Benni Mack wrote 11/29/21, 10:21

    Change destination moved from master to main
  5. Benni Mack updated the commit message in patch set 7 11/29/21, 14:10

  6. core-ci voted on patch set 7 V +1 11/29/21, 18:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/20107

  7. Nikita Hovratov uploaded patch set 8 01/17/22, 18:11

  8. Nikita Hovratov commented on patch set 8 V +1 CR +1 01/17/22, 18:13

    Reply

    We just use the PHP empty function now, as the stdWrap function ifEmpty suggests.

    ContentObjectRendererTest.php:1274 Reply

    Done
  9. Nikita Hovratov commented on patch set 8 01/17/22, 18:18

    Reply

    Done
  10. core-ci voted on patch set 8 V -1 01/17/22, 18:30 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/22190

  11. Nikita Hovratov uploaded patch set 9 01/17/22, 18:51

  12. Nikita Hovratov uploaded patch set 10 01/17/22, 18:58

  13. core-ci voted on patch set 9 V +1 01/17/22, 19:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/22193

  14. core-ci voted on patch set 10 V +1 01/17/22, 19:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/22194

  15. Nikita Hovratov voted on patch set 10 V +1 CR +1 01/17/22, 19:15

  16. Oli Bartsch uploaded patch set 11 01/19/22, 22:35

  17. Oli Bartsch commented on patch set 11 CR +1 01/19/22, 22:36

    ContentObjectRenderer.php:1457

    Can this method then be deprecated / removed? It's only used in Tests and does not seem to make any sense. Both parameters are unused. Or do I just overlook sth?
  18. Oli Bartsch commented on patch set 11 01/19/22, 22:37

    ContentObjectRenderer.php:1457 Reply

    Forget it. Anyways not part of this patch
  19. core-ci voted on patch set 11 V +1 01/19/22, 22:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/22294

  20. Oli Bartsch voted on patch set 11 V +1 01/19/22, 22:58

  21. Stefan Bürk voted on patch set 11 CR +1 01/19/22, 23:05

  22. Stefan Bürk voted on patch set 11 V +1 01/19/22, 23:28

  23. Nikita Hovratov commented on patch set 11 V +1 CR +1 01/20/22, 08:06

    ContentObjectRenderer.php:1457 Reply

    Yes, I thought the same. Can be done in another patch.
  24. Benni Mack voted on patch set 11 V +2 CR +2 01/20/22, 19:16

  25. Benni Mack merged patch set 12 01/20/22, 19:16