Use PHP7's random_int() CSPRNG functionality in wp_rand() with a fallback to the random_compat library for PHP 5.x.

`random_compat` offers a set of compatible functions for older versions of PHP, filling in the gap by using other PHP extensions when available.
We still include our existing `wp_rand()` functionality as a fallback for when no proper CSPRNG exists on the system.

Props sarciszewski
See #28633


git-svn-id: https://develop.svn.wordpress.org/trunk@34922 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse
2015-10-08 00:01:26 +00:00
parent 1fc41894d2
commit ffb7ae1389
10 changed files with 854 additions and 3 deletions

View File

@@ -332,3 +332,8 @@ if ( ! interface_exists( 'JsonSerializable' ) ) {
public function jsonSerialize();
}
}
// random_int was introduced in PHP 7.0
if ( ! function_exists( 'random_int' ) ) {
require ABSPATH . WPINC . '/random_compat/random.php';
}