Review main Merged

73519[BUGFIX] Check if vanillaUid is actually a real number

Georg Ringer CR +2 V +2 Normal +59 −19 updated 02/18/22, 16:04

Commit message

Avoid exceptions when creating inline relations if the
parent record is not yet persisted.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Oli Bartsch +1
    • Jochen Roth +1
    • Stefan Bürk +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Oli Bartsch +1
    • Jochen Roth +1
    • Stefan Bürk +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 2025

  1. Georg Ringer uploaded patch set 1 02/15/22, 11:49

  2. Georg Ringer commented on patch set 1 02/15/22, 11:49

    This change is ready for review.
  3. core-ci voted on patch set 1 V -1 02/15/22, 12:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23616

  4. Georg Ringer uploaded patch set 2 02/15/22, 12:29

  5. core-ci voted on patch set 2 V +1 02/15/22, 12:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23619

  6. Jochen Roth voted on patch set 2 V +1 CR +1 02/15/22, 12:42

  7. Oliver Klee voted on patch set 2 CR +1 02/15/22, 12:46

  8. Oli Bartsch commented on patch set 2 CR -1 02/15/22, 12:47

    Let's add some tests for this scenario. Test class already exists.
  9. Georg Ringer uploaded patch set 3 02/15/22, 13:09

  10. Oliver Klee voted on patch set 3 CR +1 02/15/22, 13:17

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

  12. Jochen Roth voted on patch set 3 V +1 CR +1 02/15/22, 13:22

  13. Oli Bartsch commented on patch set 3 02/15/22, 16:06

    DatabaseParentPageRow.php:50

    AFAICS this is a PHP version related problem, see https://3v4l.org/nk10B and https://www.php.net/manual/de/language.types.numeric-strings.php. It should therefore be fine to just cast $result['vanillaUid'] manually to an integer, see https://3v4l.org/o7mK8, to restore the previous behaviour.

    DatabaseParentPageRowTest.php:177

    Not that important, but if you update the patch again, you might want to set 'databaseRow' to an empty array here, to mimic a real use case.
  14. Georg Ringer commented on patch set 3 02/16/22, 18:41

    DatabaseParentPageRow.php:50 Reply

    true but this would hide the reason why we do it
  15. Oli Bartsch commented on patch set 3 02/16/22, 20:43

    DatabaseParentPageRow.php:50 Reply

    Actually all those conditions are odd. There is still the "$result['vanillaUid'] < 0" check which also may have side effects. Also the str_starts_with check only prevents one possibility. We're however still not sure whether $result['vanillaUid'] is an integer. This means, the actual bug (a TypeError) is not solved since we don't ensure that $result['vanillaUid'] is a valid integer. We now just ensure a string representation of the value does not start with "NEW". My suggestion was based on the assumption to just restore the previous behaviour. In case we want to even improve the code, I suggest to wrap the block e.g. into a MathUtility::canBeInterpretedAsInteger(), and to skip the block if it's not the case. Additionally, we could create a local variable, casted to int, which we then use for the < 0 and > 0 checks (Passing this to getRecordFromDatabase() is then also save). What do you think? I could do the necessary adjustments to the patch, if you like.
  16. Georg Ringer commented on patch set 3 02/16/22, 20:48

    DatabaseParentPageRow.php:50 Reply

    Pls go ahead;)
  17. Oli Bartsch uploaded patch set 4 02/16/22, 21:49

  18. Oli Bartsch uploaded patch set 5 02/16/22, 21:50

  19. core-ci voted on patch set 4 V +1 02/16/22, 21:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23757

  20. core-ci voted on patch set 5 V +1 02/16/22, 22:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/23759

  21. Oli Bartsch commented on patch set 5 V +1 CR +1 02/16/22, 22:33

    DatabaseParentPageRow.php:50 Reply

    Done

    DatabaseParentPageRowTest.php:177 Reply

    Done
  22. Jochen Roth voted on patch set 5 V +1 CR +1 02/17/22, 12:03

  23. Stefan Bürk voted on patch set 5 V +1 CR +1 02/18/22, 00:39

  24. Georg Ringer voted on patch set 5 V +2 CR +2 02/18/22, 16:04

  25. Georg Ringer merged patch set 6 02/18/22, 16:04