Review main Merged

90495[TASK] Improve user session garbage collection algorithm

TYPO3com CR +2 V +2 Easy +2 −3 updated 10/27/25, 16:23

Commit message

The session garbage probability was calculated wrongly. It randomly
picked an integer between 0-99, but compared less-or-equal to the
required probability, regarding 99 as a 100% probability, and 1 counting
as as 2% (and so on). This is fixed by using a strict lesser-than
comparison.

Also, the random number generation was over-complicated and
statistically not uniform, because it relied on the modulus
of the divisor "100" being applied to a random number out of
the range 0 to signed 32 bit maximum, not being a multiple of 100,
so the few "extra" numbers above the last whole multiple of 100
were a tiny bit more likely to be chosen (because they appear
one time more often than the "missing" numbers up to 100 inside
the "set" to randomly choose from). This was corrected by not
taking the modulo of 100 of some huge random number,
but by just getting a random number between 0-99 directly.

Also the cryptographically robust, but less than half as fast,
function `random_int` was replaced by using `rand()` instead,
to speed things up even further.
Cryptographically robustness is not needed here.

Review

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

Issues 1

Files 1

Review log 1322

  1. TYPO3com uploaded patch set 1 08/27/25, 20:31

  2. core-ci voted on patch set 1 V +1 08/27/25, 20:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83907

  3. Garvin Hicking updated the commit message in patch set 2 V +1 08/27/25, 20:42

  4. Stefan P updated the commit message in patch set 3 08/27/25, 20:49

  5. core-ci voted on patch set 2 V +1 08/27/25, 20:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83908

  6. Stefan P commented on patch set 3 08/27/25, 20:52

    `mt_getrandmax()` always returns 2^31-1 (also on 64 bit systems!), please don't change that in the commit message. Changed the message back to the original meaning.
  7. Garvin Hicking commented on patch set 3 08/27/25, 20:57

    Reply

    Indeed, thanks for noticing. I wrongly used PHP INT_MAX in the issue today and had that wrongly in mind.
  8. core-ci voted on patch set 3 V +1 08/27/25, 21:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83912

  9. Chris Müller updated the commit message in patch set 4 V +1 08/28/25, 15:02

  10. core-ci voted on patch set 4 V +1 08/28/25, 15:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83939

  11. Oliver Klee updated the commit message in patch set 5 V +1 08/28/25, 15:49

  12. core-ci voted on patch set 5 V +1 08/28/25, 15:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/83940

  13. Oliver Klee rebased onto patch set 6 V +1 10/15/25, 08:09

  14. core-ci voted on patch set 6 V +1 10/15/25, 08:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86693

  15. Markus Klein updated the commit message in patch set 7 V +1 10/15/25, 10:18

  16. Markus Klein voted on patch set 7 CR +1 V +1 10/15/25, 10:19

  17. core-ci voted on patch set 7 V +1 10/15/25, 10:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86710

  18. Oli Bartsch updated the commit message in patch set 8 CR +1 V +1 10/15/25, 11:27

  19. core-ci voted on patch set 8 V +1 10/15/25, 11:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/86714

  20. Sven Liebert voted on patch set 8 CR +1 V +1 10/18/25, 17:39

  21. Christian Kuhn voted on patch set 8 CR +2 V +2 10/27/25, 16:06

  22. Christian Kuhn merged patch set 9 10/27/25, 16:23