php-src/ext/random
Tim Düsterhus 7f0b228f48
Fix pre-PHP 8.2 compatibility for php_mt_rand_range() with MT_RAND_PHP (#9839)
* Fix pre-PHP 8.2 compatibility for php_mt_rand_range() with MT_RAND_PHP

As some left-over comments indicated:

> Legacy mode deliberately not inside php_mt_rand_range()
> to prevent other functions being affected

The broken scaler was only used for `php_mt_rand_common()`, not
`php_mt_rand_range()`. The former is only used for `mt_rand()`, whereas the
latter is used for `array_rand()` and others.

With the refactoring for the introduction of ext/random `php_mt_rand_common()`
and `php_mt_rand_range()` were accidentally unified, thus introducing a
behavioral change that was reported in FakerPHP/Faker#528.

This commit moves the checks for `MT_RAND_PHP` from the general-purpose
`range()` function back into `php_mt_rand_common()` and also into
`Randomizer::getInt()` for drop-in compatibility with `mt_rand()`.

* [ci skip] NEWS for `MT_RAND_PHP` compatibility
2022-10-28 16:52:43 +02:00
..
tests Fix pre-PHP 8.2 compatibility for php_mt_rand_range() with MT_RAND_PHP (#9839) 2022-10-28 16:52:43 +02:00
config.m4 GH-9464: Fix build on older macOs releases. 2022-09-04 02:12:28 +01:00
config.w32
CREDITS
engine_combinedlcg.c Add ext/random Exception hierarchy (#9220) 2022-08-02 20:04:28 +02:00
engine_mt19937.c Fix pre-PHP 8.2 compatibility for php_mt_rand_range() with MT_RAND_PHP (#9839) 2022-10-28 16:52:43 +02:00
engine_pcgoneseq128xslrr64.c random: Validate that the arrays do not contain extra elements when unserializing (#9458) 2022-09-05 17:33:36 +02:00
engine_secure.c Add ext/random Exception hierarchy (#9220) 2022-08-02 20:04:28 +02:00
engine_user.c Add ext/random Exception hierarchy (#9220) 2022-08-02 20:04:28 +02:00
engine_xoshiro256starstar.c random: Validate that the arrays do not contain extra elements when unserializing (#9458) 2022-09-05 17:33:36 +02:00
php_random.h [ci skip] Trim trailing whitespace in php_random.h 2022-10-03 20:32:37 +02:00
random_arginfo.h Do not generate CONST_CS when registering constants (#9439) 2022-08-28 08:27:19 +02:00
random.c Fix pre-PHP 8.2 compatibility for php_mt_rand_range() with MT_RAND_PHP (#9839) 2022-10-28 16:52:43 +02:00
random.stub.php Add ext/random Exception hierarchy (#9220) 2022-08-02 20:04:28 +02:00
randomizer.c Fix pre-PHP 8.2 compatibility for php_mt_rand_range() with MT_RAND_PHP (#9839) 2022-10-28 16:52:43 +02:00