#
350883db |
| 27-Nov-2022 |
Tim Düsterhus |
[ci skip] random: Trim trailing whitespace in randomizer.c To keep the diff cleaner for future changes, such as #9664. |
#
7f0b228f |
| 28-Oct-2022 |
Tim Düsterhus |
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 in
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
show more ...
|
#
ca399841 |
| 20-Sep-2022 |
Joshua Rüsweg |
Remove superfluous helper variable in `Randomizer::getBytes()` (#9563) * Remove superfluous helper variable in Randomizer::getBytes() * Reduce the scope of `result` in Randomizer::g
Remove superfluous helper variable in `Randomizer::getBytes()` (#9563) * Remove superfluous helper variable in Randomizer::getBytes() * Reduce the scope of `result` in Randomizer::getBytes() Co-authored-by: Tim Düsterhus <tim@bastelstu.be>
show more ...
|
#
ddf7a5d4 |
| 05-Sep-2022 |
Tim Düsterhus |
random: Validate that the arrays do not contain extra elements when unserializing (#9458) * Apply `var_dump()` in 02_engine/all_serialize_error.phpt This ensures that an undetected
random: Validate that the arrays do not contain extra elements when unserializing (#9458) * Apply `var_dump()` in 02_engine/all_serialize_error.phpt This ensures that an undetected serialization error is clear identifiable in the output. * random: Validate that the arrays do not contain extra elements when unserializing
show more ...
|
#
adb45a63 |
| 30-Aug-2022 |
Máté Kocsis |
Fix GH-9186 @strict-properties can be bypassed using unserialization (#9354) * Emit deprecation warnings when adding dynamic properties to classes during unserialization - this will become a
Fix GH-9186 @strict-properties can be bypassed using unserialization (#9354) * Emit deprecation warnings when adding dynamic properties to classes during unserialization - this will become an Error in php 9.0. (Adding dynamic properties in other contexts was already a deprecation warning - the use case of unserialization was overlooked) * Throw an error when attempting to add a dynamic property to a `readonly` class when unserializing * Add new serialization methods `__serialize`/`__unserialize` for SplFixedArray to avoid creating deprecated dynamic properties that would then be added to the backing fixed-size array * Don't add named dynamic/declared properties (e.g. $obj->foo) of SplFixedArray to the backing array when unserializing * Update tests to declare properties or to expect the deprecation warning * Add news entry Co-authored-by: Tyson Andre <tysonandre775@hotmail.com>
show more ...
|
#
3b48a204 |
| 15-Aug-2022 |
Tim Düsterhus |
Replace RuntimeException in Randomizer::nextInt() by RandomException (#9305) * Replace RuntimeException in Randomizer::nextInt() by RandomException * Add ext/random/tests/03_randomi
Replace RuntimeException in Randomizer::nextInt() by RandomException (#9305) * Replace RuntimeException in Randomizer::nextInt() by RandomException * Add ext/random/tests/03_randomizer/nextint_error.phpt
show more ...
|
#
a6922fde |
| 02-Aug-2022 |
Tim Düsterhus |
Clean up the implementation of Randomizer::__construct() (#9222) * Verify that the engine doesn't change in construct_twice.phpt * Clean up the implementation of Randomizer::__const
Clean up the implementation of Randomizer::__construct() (#9222) * Verify that the engine doesn't change in construct_twice.phpt * Clean up the implementation of Randomizer::__construct() Instead of manually checking whether the constructor was already called, we rely on the `readonly` modifier of the `$engine` property. Additionally use `object_init_ex()` instead of manually calling `->create_object()`.
show more ...
|
#
54e406cc |
| 02-Aug-2022 |
Tim Düsterhus |
Clean up nested exceptions without value-add in ext/random (#9211) * Remove exception in Randomizer::shuffleBytes() The only way that `php_binary_string_shuffle` fails is when the e
Clean up nested exceptions without value-add in ext/random (#9211) * Remove exception in Randomizer::shuffleBytes() The only way that `php_binary_string_shuffle` fails is when the engine itself fails. With the currently available list of engines we have: - Mt19937 : Infallible. - PcgOneseq128XslRr64: Infallible. - Xoshiro256StarStar : Infallible. - Secure : Practically infallible on modern systems. Exception messages were cleaned up in GH-9169. - User : Error when returning an empty string. Error when seriously biased (range() fails). And whatever Throwable the userland developer decides to use. So the existing engines are either infallible or throw an Exception/Error with a high quality message themselves, making this exception not a value-add and possibly confusing. * Remove exception in Randomizer::shuffleArray() Same reasoning as in the previous commit applies. * Remove exception in Randomizer::getInt() Same reasoning as in the previous commit applies. * Remove exception in Randomizer::nextInt() Same reasoning as in the previous commit applies, except that it won't throw on a seriously biased user engine, as `range()` is not used. * Remove exception in Randomizer::getBytes() Same reasoning as in the previous commit applies. * Remove exception in Mt19937::generate() This implementation is shared across all native engines. Thus the same reasoning as the previous commits applies, except that the User engine does not use this method. Thus is only applicable to the Secure engine, which is the only fallible native engine. * [ci skip] Add cleanup of Randomizer exceptions to NEWS
show more ...
|
#
c63f18dd |
| 02-Aug-2022 |
Tim Düsterhus |
Unify ext/random unserialize errors with ext/date (#9185) * Unify ext/random unserialize errors with ext/date - Use `Error` instead of `Exception`. - Adjust wording. *
Unify ext/random unserialize errors with ext/date (#9185) * Unify ext/random unserialize errors with ext/date - Use `Error` instead of `Exception`. - Adjust wording. * Make `zend_read_property` silent in `Randomizer::__unserialize()` Having: > Error: Typed property Random\Randomizer::$engine must not be accessed before > initialization is not a value-add in this case. * Insert the actual class name in the unserialization error of Engines * Revert unserialization failure back to Exception from Error see https://news-web.php.net/php.internals/118311
show more ...
|
#
4e92c746 |
| 30-Jul-2022 |
zeriyoshi |
random: split Randomizer::getInt() without argument to Randomizer::nextInt() Since argument overloading is not safe for reflection, the method needed to be split appropriately.
random: split Randomizer::getInt() without argument to Randomizer::nextInt() Since argument overloading is not safe for reflection, the method needed to be split appropriately. Co-authored-by: Tim Düsterhus <timwolla@googlemail.com> Closes GH-9057.
show more ...
|
#
5c693c77 |
| 26-Jul-2022 |
Tim Düsterhus |
Remove `->last_unsafe` from php_random_status (#9132) Whenever ->last_unsafe is set to `true` an exception has been thrown. Thus we can replace the check for `->last_unsafe` with a check
Remove `->last_unsafe` from php_random_status (#9132) Whenever ->last_unsafe is set to `true` an exception has been thrown. Thus we can replace the check for `->last_unsafe` with a check for `EG(exception)` which is a much more natural way to ommunicate an error up the chain.
show more ...
|
#
34b352d1 |
| 23-Jul-2022 |
Go Kudo |
Fix memory leak on Randomizer::__construct() call twice (#9091) When Radomizer::__construct() was called with no arguments, Randomizer\Engine\Secure was implicitly instantiate and memory was
Fix memory leak on Randomizer::__construct() call twice (#9091) When Radomizer::__construct() was called with no arguments, Randomizer\Engine\Secure was implicitly instantiate and memory was leaking. Co-authored-by: Tim Düsterhus <timwolla@googlemail.com>
show more ...
|
#
e4c89498 |
| 21-Jul-2022 |
Go Kudo |
[ci skip] Update EXTENSIONS and Author(s) in ext/random (#9074) php.net account is better suited for this cases. |
#
4d8dd8d2 |
| 19-Jul-2022 |
Go Kudo |
Implement Random Extension https://wiki.php.net/rfc/rng_extension https://wiki.php.net/rfc/random_extension_improvement |