Review main Merged

74677[TASK] Resolve more dead code paths

crell CR +2 V +2 Easy +5 −25 updated 06/09/22, 07:30

Commit message

More code paths identified as dead by PHPStan, or
that PHPStan isn't understanding correctly.

Used command:

> Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Review

  • Code review CR +2 Done
    • Nikita Hovratov +2
    • Joey Bouten +1
    • Stefan Bürk +1
  • Verified V +2 Done
    • Nikita Hovratov +2
    • Stefan Bürk +1
    • core-ci +1 CI

Issues 1

Files 5

Review log 2024

  1. crell uploaded patch set 1 05/17/22, 23:03

  2. core-ci voted on patch set 1 V +1 05/17/22, 23:10 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27291

  3. Simon Schaufelberger commented on patch set 1 05/18/22, 10:54

    PageLayoutView.php:1001

    Did you test that and can confirm that this is really dead code?
  4. crell commented on patch set 1 05/18/22, 13:29

    PageLayoutView.php:1001 Reply

    Not manually; I assumed the test bot would catch it if there was something wonky. However, from static analysis, none of it gets used. $out is always set to a string immediately before the if, so it will never be false. (This is what PHPStan noted.) So that is irrelevant. Both branches of the if statement overwrite $out, so whatever it's set to before that is irrelevant. So remove that. $confirm is only used in $out, but since $out is irrelevant so is $confirm. $refCountMsg is only used in $confirm. $params is only used in $out. So while those lines were executed, they ultimately do nothing but burn CPU cycles.
  5. Simon Schaufelberger commented on patch set 1 05/18/22, 14:08

    PageLayoutView.php:1001 Reply

    Yes, $out is always true but $out is a concatenated string and you just removed a whole code block which should be wrapped but is now missing a lot of HTML. I can't believe this is dead.
  6. crell commented on patch set 1 05/18/22, 15:04

    PageLayoutView.php:1001 Reply

    I looked it over again, and interestingly you're right. I goofed and while both if branches overwrite $out, one of them uses out in doing so, so its value is not wasted. I'll revert that part of the patch. However, that means there's some missing test coverage as CI should have caught this.
  7. crell uploaded patch set 2 05/18/22, 15:04

  8. core-ci voted on patch set 2 V +1 05/18/22, 15:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27304

  9. Nikita Hovratov uploaded patch set 3 05/18/22, 15:45

  10. Nikita Hovratov voted on patch set 3 V +1 CR +1 05/18/22, 15:48

  11. core-ci voted on patch set 3 V +1 05/18/22, 15:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27305

  12. Simon Schaufelberger voted on patch set 3 CR +1 05/18/22, 16:33

  13. Stefan Bürk commented on patch set 3 05/28/22, 22:44

    PageLayoutView.php:1025

    This looks kind of weired/dangerous - or do i get something wrong ? if $delete is disabled, this would not be checked. If not, this may be checked and when having insufficent permissiones, this will clean all in $out, not just the $deleteButton part - however, not related to this patch. Or is it only me struggling with this when seeing it ? Not as blocker for this patch - but may someone confirm this feeling here before getting this patch merged ?
  14. Oliver Klee commented on patch set 3 05/29/22, 10:04

    PageLayoutView.php:1025 Reply

    I line 1014, $out gets appended some non-empty and non-falsy string. So $out will always be truthy in line 2021, and this change is correct.
  15. Stefan Bürk commented on patch set 3 05/29/22, 11:17

    PageLayoutView.php:1025 Reply

    You got me wrong. removing the $out from the condition is obious and not my question. My quetion is about the "else" branch here doing $out = '' in conjuntion with L1000 condition. If $disableDelete is not true and $this->hasContentModificationAndAccesspermissions() will return false, it will empty out $out - but only in that constellation. This would not only clearing L1014, but also L972-L974 + eventually set L990-L992. And that is what I'm asking for .. 1) is the clearing of the previous set complet out okay here and 2) should the check eventually be outside $disableDelete or $out eventually used as "early" check to avoid amending to $out ??
  16. Oliver Klee commented on patch set 3 05/29/22, 11:37

    PageLayoutView.php:1025 Reply

    Oh. :-) I'd indeed recommend to make it a guard clause/early check, but in a separate change with a dedicated ticket.
  17. Stefan Bürk commented on patch set 3 05/30/22, 05:14

    PageLayoutView.php:1025 Reply

    Sure .. already said, not as blocker for this patch - just wanted to have someone confirm this point ;).
  18. Stefan Bürk updated the commit message in patch set 4 05/30/22, 05:15

  19. Stefan Bürk voted on patch set 4 V +1 CR +1 05/30/22, 05:15

  20. core-ci voted on patch set 4 V +1 05/30/22, 05:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27576

  21. Oliver Klee wrote 06/07/22, 17:43

    Removed cc Oliver Klee.
  22. Joey Bouten voted on patch set 4 CR +1 06/08/22, 12:35

  23. Nikita Hovratov voted on patch set 4 V +2 CR +2 06/09/22, 07:29

  24. Nikita Hovratov merged patch set 5 06/09/22, 07:30