Review main Merged

84180[BUGFIX] Skip invalid languages in integrityservice of redirects

Georg Ringer CR +2 V +2 Easy +13 −4 updated 05/15/24, 06:11

Commit message

It might be that pages are still available which are outdated regarding
its language. This can be when a site language has been removed from the
configuration.

Therefore those pages should be skipped when checking the integrity.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Josef Glatz +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Josef Glatz +1
    • core-ci +1 CI

Issues 1

Files 1

Review log 1517

  1. Georg Ringer uploaded patch set 1 05/08/24, 15:32

  2. Georg Ringer commented on patch set 1 05/08/24, 15:33

    This change is ready for review.
  3. core-ci voted on patch set 1 V +1 05/08/24, 15:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57412

  4. Stefan Bürk commented on patch set 1 CR -1 05/10/24, 17:42

    I guess it should more marked as invalid (site language missing) instead if simply skipping it. Will look on it again ...
  5. Stefan Bürk commented on patch set 1 05/11/24, 17:48

    Reply

    My bad. Missunderstood that place. It fetches all pages and checks if there is a redirect conflicting with a page slug. If a site language has been dropped, this would lead to errors. This this change is okay. However, the same thing needs to be done in `getSlugsOfSubPages()`
  6. Stefan Bürk uploaded patch set 2 CR -1 V +1 05/11/24, 17:49

  7. Stefan Bürk commented on patch set 2 05/11/24, 17:51

    Reply

    Done
  8. core-ci voted on patch set 2 V +1 05/11/24, 17:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57523

  9. Stefan Bürk voted on patch set 2 CR +1 V +1 05/11/24, 17:55

  10. Josef Glatz commented on patch set 2 CR +1 V +1 05/13/24, 12:19

    tested successfully in my two realworld projects
  11. Josef Glatz commented on patch set 2 05/13/24, 13:20

    any chance to get this also in TYPO3 11.5 backported?
  12. Stefan Bürk voted on patch set 2 CR +2 V +2 05/13/24, 16:22

  13. Stefan Bürk commented on patch set 2 05/13/24, 16:24

    Reply

    No, v11 is in security & priority bugfix mode. Literally, this mitigates only corrupt data/configuration and the that should be fixed anyway.
  14. Stefan Bürk merged patch set 3 05/13/24, 16:32

  15. Helmut Strasser commented on patch set 3 05/14/24, 14:11

    Sorry for sliding in, but... I don't catch the point of using the control structure "continue" in the catch block. php.net: "continue is used within looping structures to skip the rest of the current loop iteration". A catch block without any content "does nothing" and continues code execution. Do I get something wrong?
  16. Stefan Bürk commented on patch set 3 05/15/24, 02:44

    Reply

    Basically, `continue` is a control statement within loops (for, while, ...) to continue with the next loop interation, aborting the remaining code execution for the loop body on the current item. In this case, a `while` loop is used to iterate over the result set, determining the site and siteLanguage a database record ($row), trying to retrieve the siteLanguage by the record language from the siteConfiguration. If there is no siteLanguage for the site for the given languageId, an `InvalidArgumentException` is thrown within the `$siteLanguage = $site->getLanguageById($lang);` call. This states an error and was not handled before this change, leading to an uncontrollerd abort of the whole command not processing further items. Thus, this change catches this exception and skip to the next database result item ($row), skipping the rest of the loop body for the current $row and continue executing the loop for the next database record. > A catch block without any content "does nothing" and continues code execution. That means, if you have a try-catch construct with a catch without any code, something like following ``` try { // do something ... } catch(\Exception) { // empty catch block without any code line } ``` it would continue to execute code after the catch block - simply silencing the exception and not break out of the script execution (or to a handling try/catch). > continue is used within looping structures to skip the rest of the current loop iteration" That is exactly what is done here now: we have a `continue` statement in catch block, avoiding executing the code after the try-catch block for the current loop iteration ($row) and continue with the next result OR after the loop if it was the last loop item. `continue` does not need to be directly in the loop, it can be nested within sub blocks (if-constructs, switch/match constructs, ...). It also alows to state the continue level if nested loops are used and you want to continue on a higher (outer) loop instead. Similar to break. > Do I get something wrong? Tried to explain it above, and without wanted to be mean - yes, you got that wrong. But I hope it is now clearer with the explanation above. Resolving this comment now, as the construct is absolutly correct (and the only way to properly handle an error case and continue with next row in this case).
  17. Helmut Strasser commented on patch set 3 05/15/24, 06:11

    Reply

    Hm, big mistake. Didn't even notice we are in a loop. Thx a lot for the detailed and elucidating explanation!