Review main Merged

52416[TASK] Switch isset() and is_array() to null coalesce

Claus Due CR +2 V +2 Nightmare +1118 −1668 updated 12/07/17, 16:00

Commit message

Several hundred function calls and vast numbers
of indentations can be saved by using the null
coalesce operator instead of checking empty/array.

Review

  • Code review CR +2
    • Wouter Wolters +2
    • Susi Moog +1
  • Verified V +2
    • Wouter Wolters +2
    • Susi Moog +1
    • TYPO3com +1 CI

Issues 1

Files 100

Show 80 more files

Review log 4557

Show 2432 earlier messages
  1. Claus Due uploaded patch set 1 04/11/17, 15:59

  2. TYPO3com voted on patch set 1 V -1 04/11/17, 16:06 Completed build in 07m 05s on Tue, 11 Apr, 06:06 PM Test Summary: 6 of 56651 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-10474

  3. Claus Due uploaded patch set 2 04/11/17, 16:14

  4. TYPO3com voted on patch set 2 V -1 04/11/17, 16:24 Completed build in 09m 22s on Tue, 11 Apr, 06:24 PM Test Summary: 56642 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-10475

  5. Claus Due uploaded patch set 3 04/11/17, 18:20

  6. TYPO3com voted on patch set 3 V +1 04/11/17, 18:31 Completed build in 10m 50s on Tue, 11 Apr, 08:31 PM Test Summary: 56642 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-10477

  7. Claus Due uploaded patch set 4 05/22/17, 18:26

  8. TYPO3com voted on patch set 4 V -1 05/22/17, 18:34 Completed build in 07m 38s on Mon, 22 May, 08:34 PM Test Summary: 55889 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-11728

  9. Claus Due uploaded patch set 5 05/22/17, 18:40

  10. TYPO3com voted on patch set 5 V +1 05/22/17, 18:47 Completed build in 06m 36s on Mon, 22 May, 08:47 PM Test Summary: 55889 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-11730

  11. Oliver Klee commented on patch set 5 CR -1 05/22/17, 20:06

    ModulesController.php:77

    If I understand this correctly, this will crash (or at least throw a PHP warning) if the array element is non-null, but not an array (e.g., a string). This is a general problem with replacing an is_array with ??.

    ModulesController.php:78

    This change does not seem to be related.
  12. Claus Due commented on patch set 5 05/31/17, 12:29

    ModulesController.php:77 Reply

    This is correct, rather than ignore the array an error would now be shown. If debug mode is enabled the error will even include this very line so the dev can see exactly which hook array he misconfigured. One might argue ignoring is better but there seems to be a preference for verbose errors rather than silent ignoring in pretty much all other areas of TYPO3. (plus, we're saving a hell of a lot of calls to is_array)

    ModulesController.php:78 Reply

    Oops, yes - caused during conflict resolving due to a patch lolli made which touched *every* loop I also touched in this patch. This works, but unintentionally reverts lolli's change in this line.
  13. Claus Due commented on patch set 6 05/31/17, 12:29

    Published edit on patch set 5.
  14. TYPO3com voted on patch set 6 V +1 05/31/17, 12:37 Completed build in 07m 11s on Wed, 31 May, 02:37 PM Test Summary: 55889 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-11905

  15. Oliver Klee commented on patch set 5 05/31/17, 14:21

    ModulesController.php:77 Reply

    Then this should not be marked as CLEANUP, but as a breaking (!!!) CHANGE, as this is a change to the behavior.
  16. Oliver Klee commented on patch set 6 CR -1 05/31/17, 14:22

    This then needs to marked as breaking, and as a TASK, not at as CLEANUP.
  17. Claus Due commented on patch set 6 06/13/17, 11:16

    Not sure I agree about the breaking part - maybe we can meet half way and I'll add an important RST that says "used to ignore bad config, now reports it". My reasoning is that because invalid entries would be ignored before this patch, the likelihood that any production setup contains an invalid entry is absolutely minimal. If it does, then that is an error (and the registered hook would never have worked anyway). The error it does throw is a NOTICE and assuming people use recommended setups, would only be shown in development sites.
  18. Tymoteusz Motylewski commented on patch set 6 CR -2 11/05/17, 20:31

  19. Helmut Hummel commented on patch set 6 CR -1 11/06/17, 10:24

    I did not go through the complete patch, but found some places where rebase went wrong

    ElementInformationController.php:215

    needs to stay makeInstance. maybe a wrong rebase?

    NewContentElementController.php:228

    same here

    BackendUtility.php:2505

    same here
  20. Tymoteusz Motylewski commented on patch set 6 CR 0 11/07/17, 13:43

    we have green light from Benni.
  21. Helmut Hummel commented on patch set 6 11/07/17, 14:40

    I would agree that this is not a cleanup, but rather a task, or even a feature. It does not harm to mark this as breaking, although it only breaks, when there is a dev error that needs a fix anyway
  22. Stefan Neufeind commented on patch set 6 11/09/17, 11:29

    @Claus: Can you look into this again? Or should I help out? Let's get this through so it doesn't conflict to often with other merges inbetween.
  23. Claus Due commented on patch set 6 11/09/17, 11:31

    I will take absolutely any help you want to give - I am working ~10 hours a day on a project for the next three months so my availability is extremely low.
  24. Stefan Neufeind uploaded patch set 7 11/10/17, 00:54

  25. TYPO3com voted on patch set 7 V -1 11/10/17, 00:55 Completed build in 22s on Fri, 10 Nov, 01:55 AM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-16225

  26. Stefan Neufeind commented on patch set 7 11/10/17, 00:55

    rebased, fixed, extended Turned this into a "[TASK]" now.
  27. Stefan Neufeind uploaded patch set 8 11/10/17, 01:00

  28. TYPO3com voted on patch set 8 V +1 11/10/17, 01:11 Completed build in 10m 19s on Fri, 10 Nov, 02:11 AM Test Summary: 56762 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-16226

  29. Stefan Neufeind commented on patch set 8 CR +1 11/11/17, 15:59

    Could somebody take a look, please?
  30. Jörg Bösche voted on patch set 8 CR +1 11/13/17, 11:23

  31. Tymoteusz Motylewski commented on patch set 8 11/13/17, 12:30

    DataProvider.php:78

    missing ?? [] ?

    PageLayoutView.php:2063

    is removal of the &-reference backward compatible?

    PageLayoutView.php:2169

    are you sure we don't need parenthesis around inner "??" ?
  32. Stefan Neufeind commented on patch set 8 CR -1 11/13/17, 12:44

    DataProvider.php:78 Reply

    Thanks. I'll then take care of this one with the next round.

    PageLayoutView.php:2063 Reply

    since we only iterated over it to fetch the classNames I don't see a problem and the reference wasn't really needed. Or do you have some specialcase in mind? Well, in theory with a reference the foreach might be resetting the internal array-iterator of that array - but I expect that's unlikely to make a difference.

    PageLayoutView.php:2169 Reply

    you mean since it is two times ?? now? I just tested this here and it works for me as expected: foreach ($a ?? $b ?? ['default'] as $x)
  1. Tymoteusz Motylewski commented on patch set 8 CR -1 11/13/17, 15:10

    GeneralUtility.php:3544

    do we need "?? false" here? empty doesn't throw a notice when array key does not exist, so additional check for isset (??) sounds unnecessary.

    GeneralUtility.php:3806

    same here, ?? is probably unnecessary.

    ContentObjectRenderer.php:1456

    $_params got lost, don't they?

    AbstractDatabaseRecordList.php:713

    this comment should not be removed right?

    DataHandlerHook.php:609

    it was not passed as reference before.
  2. Stefan Neufeind commented on patch set 9 11/14/17, 07:10

    Published edit on patch set 8.
  3. Stefan Neufeind commented on patch set 9 11/14/17, 07:11

    @Tymek: Took care of the missing ?? [] in DataProvider.php. Imho the other cases you asked about are okay (as I commented)? If you feel different please speak up.
  4. TYPO3com voted on patch set 9 V +1 11/14/17, 07:25 Completed build in 14m 37s on Tue, 14 Nov, 08:25 AM Test Summary: 56762 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-16313

  5. Tymoteusz Motylewski commented on patch set 9 CR -1 11/14/17, 08:09

    @Stefan, please also take a look at the comments I gave on the left side (original file). e.g. in ContentObjectRenderer.php line 1456
  6. Tymoteusz Motylewski commented on patch set 9 11/14/17, 08:13

    also some other comments were also not taken into account like passing as a reference which was not there before. Please review all my comments to patchset 8 (I submitted them in 2 parts).
  7. Tymoteusz Motylewski commented on patch set 9 11/14/17, 17:39

    few more place are not covered: GeneralUtility::minifyJavascript and SignalSlot/Dispatcher.php::connect - line 95
  8. Tymoteusz Motylewski commented on patch set 8 11/20/17, 10:34

    will push a followup in a second

    GeneralUtility.php:3544 Reply

    Done

    AbstractDatabaseRecordList.php:713 Reply

    Done

    DataHandlerHook.php:609 Reply

    Done
  9. Tymoteusz Motylewski uploaded patch set 10 11/20/17, 10:34

  10. TYPO3com voted on patch set 10 V +1 11/20/17, 10:45 Completed build in 10m 45s on Mon, 20 Nov, 11:45 AM Test Summary: 56802 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-16488

  11. Tymoteusz Motylewski uploaded patch set 11 11/20/17, 19:29

  12. TYPO3com voted on patch set 11 V +1 11/20/17, 19:46 Completed build in 16m 53s on Mon, 20 Nov, 08:46 PM Test Summary: 56802 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-16506

  13. Tymoteusz Motylewski voted on patch set 11 CR +1 V +1 11/24/17, 22:20

  14. Stefan Neufeind commented on patch set 11 CR +1 V +1 11/24/17, 22:45

    @Tymek: thanks for taking care of some more cases
  15. Wouter Wolters voted on patch set 11 CR +1 11/25/17, 14:14

  16. Tymoteusz Motylewski uploaded patch set 12 11/27/17, 11:35

  17. TYPO3com voted on patch set 12 V +1 11/27/17, 11:44 Completed build in 08m 53s on Mon, 27 Nov, 12:44 PM Test Summary: 56802 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-16646

  18. Tymoteusz Motylewski commented on patch set 12 11/27/17, 11:47

    rebased
  19. Wouter Wolters voted on patch set 12 CR +1 11/27/17, 20:44

  20. Susi Moog voted on patch set 12 CR +1 11/27/17, 21:03

  21. Susi Moog voted on patch set 12 V +1 11/27/17, 21:07

  22. Wouter Wolters voted on patch set 12 CR +2 V +2 11/27/17, 21:19

  23. Gerrit merged patch set 12 11/27/17, 21:19

  24. Benni Mack commented on patch set 13 12/07/17, 15:51

    will fix.

    RteHtmlParser.php:546

    regression: After this change, the "else" part is always executed. The point of the hook was that it was EITHER hooked, or processed regularly.
  25. Stefan Neufeind commented on patch set 13 12/07/17, 16:00

    RteHtmlParser.php:546 Reply

    @Claus: Can you give a reason for that change? Seems to have been like this from patchset 4 on.