Review main Merged

74636[BUGFIX] Remove dead-code paths from AddController

crell CR +2 V +2 Normal +11 −41 updated 07/12/22, 18:55

Commit message

PHPStan identified these code paths as impossible. On
code inspection that's true, so they have been removed
as dead code.  That allowed for the properties of the
class to be typed.

Small related cleanup is included to make verifying
that the code paths were indeed dead easier.

Review

  • Code review CR +2 Done
    • Christian Kuhn +2
    • Benni Mack +1
  • Verified V +2 Done
    • Christian Kuhn +2
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 2328

Show 23 earlier messages
  1. crell uploaded patch set 1 05/12/22, 20:59

  2. core-ci voted on patch set 1 V +1 05/12/22, 21:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27153

  3. Oli Bartsch commented on patch set 1 05/12/22, 21:14

    AddController.php:43

    Since below properties are not initialised in the constructor, they should get a default value. Otherwise this might lead to errors, such as "Typed property must not be accessed before initialization".
  1. crell commented on patch set 1 05/12/22, 21:40

    AddController.php:43 Reply

    Done
  2. crell uploaded patch set 2 05/12/22, 21:40

  3. core-ci voted on patch set 2 V +1 05/12/22, 21:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27155

  4. Stefan Bürk updated the commit message in patch set 3 05/13/22, 00:50

  5. core-ci voted on patch set 3 V +1 05/13/22, 00:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27162

  6. Oliver Klee voted on patch set 3 CR +1 05/13/22, 12:54

  7. Stefan Bürk uploaded patch set 4 05/13/22, 17:21

  8. core-ci voted on patch set 4 V +1 05/13/22, 17:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27186

  9. Oliver Klee wrote 05/18/22, 19:41

    Removed reviewer Oliver Klee.
  10. crell uploaded patch set 5 05/31/22, 14:54

  11. core-ci voted on patch set 5 V +1 05/31/22, 15:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27603

  12. Oliver Klee commented on patch set 5 05/31/22, 19:13

    I propose moving the cleanup to a pre-patch to make both changes easier to review (and easier to revert in case of problems).
  13. crell commented on patch set 5 06/01/22, 17:44

    Reply

    I don't know which parts you mean. Nearly all the changes here are inter-related. The PHPstan-identified dead code is fully resolved by typing the properties. They're a package deal. I think the only thing that could really be split off is the substr/str_ends_with change, and I really see little point in splitting that off to a standalone patch. This patch is already small and self-contained at under 50 lines of code changes, both addition and removal.
  14. Oliver Klee commented on patch set 5 06/01/22, 17:58

    Reply

    I’m thinking of a change series like this: 1.a) add native types 1.b) use str_starts_with 2. remove dead code
  15. Benni Mack commented on patch set 5 06/07/22, 14:43

    Reply

    Looking a bit closer on this patch, we might actually have a regression (which we would cover up now). Using "add" wizard on new records (without any PID) should be different than records on pid=0, which should also continue to work. That's why the @todo is there. In addition, I don't know if we should make the patch (which is basically a comparably small change in just one file) even smaller, reviews are rare these days and making three changes... you know what, while I'm writing these lines, I could have made the changes myself... :) Small reminder to myself ;)
  16. Oliver Klee commented on patch set 5 06/07/22, 14:50

    Reply

    I can only speak for myself here: I am more willing/able to do a review if I see how the changes relate to the goal of the change, and if there is only one goal. (And if I don't understand part of the changes, I cannot +1 the change. So splitting the different goals up into separate changes, I will be able to review the changes I do understand.)
  17. Oliver Klee wrote 06/07/22, 17:42

    Removed cc Oliver Klee.
  18. crell commented on patch set 5 06/07/22, 19:35

    Reply

    Benni: Does that mean an empty string pid is currently being used as a sentinel value? It's not clear to me where it is even being set. Also, I just checked and it appears this class is untested; so, there's that... If it's a sentinel value and we need to keep that option, then we could make it an int|string union, but probably a better alternative, since it's an internal class, is to pick a better sentinel value (either null or an enum value defined for just this purpose or 0 or something). Where does the value get set from?
  19. Benni Mack commented on patch set 5 06/13/22, 11:59

    Reply

    OK. Tried to reproduce this with EXT:styleguide. pid=0 is valid and handed over, also on new elements, the pid is always int and > 0. So if the PID is not handed in via the request, I guess we should do nothing (PID must be given).
  20. crell commented on patch set 5 07/08/22, 14:14

    Reply

    (I said this in chat, but repeating here in case it got forgotten.) I don't know what that means for this patch. Should we still support an empty string? Or is the code good as is, and we should resolve this thread?
  21. Benni Mack commented on patch set 5 07/11/22, 14:35

    Reply

    Just saying that we can remove the dead code as the removed code is not in use anymore (= always called with a &pid query parameter).
  22. crell commented on patch set 5 07/11/22, 15:08

    Reply

    Thanks for verifying. This patch should be good to go then as-is.
  23. Benni Mack voted on patch set 5 V +1 CR +1 07/12/22, 18:52

  24. Christian Kuhn voted on patch set 5 V +2 CR +2 07/12/22, 18:55

  25. Christian Kuhn merged patch set 6 07/12/22, 18:55