Review main Merged

84141[TASK] Deprecate `MathUtility::convertToPositiveInteger()`

Andreas Kienast CR +2 V +2 Normal +96 −14 updated 05/03/24, 09:31

Commit message

TYPO3 has a method to ensure an integer is always positive:
`MathUtility::convertToPositiveInteger()`. However, the method is
rather "heavy" as it internally calls `MU::forceIntegerInRange()` and
therefore misuses a clamp mechanism to convert the integer to a
positive number.

Also, the method name doesn't reflect what it actually does. Negative
numbers are not converted to their positive counterpart, but are
swapped with `0`. Due to the naming issue and the fact that the method
can be superseded by a simple `max()` call, the method is therefore
deprecated.

Review

  • Code review CR +2 Done
    • Andreas Kienast +2
    • Benjamin Franzke +1
    • Oliver Klee +1
    • Torben Hansen +1
  • Verified V +2 Done
    • Andreas Kienast +2
    • Oliver Klee +1
    • Torben Hansen +1
    • core-ci +1 CI

Issues 1

Files 6

Review log 1416

  1. Andreas Kienast uploaded patch set 1 05/03/24, 07:26

  2. Andreas Kienast uploaded patch set 2 05/03/24, 07:26

  3. Benjamin Franzke commented on patch set 1 CR -1 05/03/24, 07:27

    MathUtility.php:59

    as `abs` has different behavior, we should recommend "use `max(0, $theInt)` instead".
  4. Benjamin Franzke commented on patch set 2 05/03/24, 07:28

    MathUtility.php:59 Reply

    Done
  5. core-ci voted on patch set 2 V +1 05/03/24, 07:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57160

  6. Oliver Klee voted on patch set 2 CR +1 V +1 05/03/24, 07:36

  7. Benjamin Franzke commented on patch set 2 05/03/24, 07:43

    EditDocumentController.php:914

    I'm not sure whether viewId is always an int (read from the form data result compiler). Better force-cast `$pageId` to `(int)` until we have defined types.
  8. Andreas Kienast commented on patch set 2 05/03/24, 07:48

    EditDocumentController.php:914 Reply

    It's not necessary, `this->popViewId` and `$this->viewId` are cast to int on write.
  9. Andreas Kienast commented on patch set 2 CR -1 05/03/24, 07:49

    EditDocumentController.php:914 Reply

    Never mind, this->viewId actually isn't. Will add the int cast.
  10. Andreas Kienast uploaded patch set 3 CR +1 V +1 05/03/24, 07:52

  11. core-ci voted on patch set 3 V +1 05/03/24, 07:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/57161

  12. Oliver Klee voted on patch set 3 CR +1 V +1 05/03/24, 08:13

  13. Torben Hansen voted on patch set 3 CR +1 V +1 05/03/24, 09:29

  14. Benjamin Franzke voted on patch set 3 CR +1 05/03/24, 09:31

  15. Andreas Kienast voted on patch set 3 CR +2 V +2 05/03/24, 09:31

  16. Andreas Kienast merged patch set 4 05/03/24, 09:31