mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-27 16:04:31 +00:00
Optimize wp_rand(), only check transient when needed. Fixes #12144.
git-svn-id: https://develop.svn.wordpress.org/trunk@13080 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1492,11 +1492,10 @@ if ( !function_exists('wp_rand') ) :
|
||||
function wp_rand( $min = 0, $max = 0 ) {
|
||||
global $rnd_value;
|
||||
|
||||
$seed = get_transient('random_seed');
|
||||
|
||||
// Reset $rnd_value after 14 uses
|
||||
// 32(md5) + 40(sha1) + 40(sha1) / 8 = 14 random numbers from $rnd_value
|
||||
if ( strlen($rnd_value) < 8 ) {
|
||||
$seed = get_transient('random_seed');
|
||||
$rnd_value = md5( uniqid(microtime() . mt_rand(), true ) . $seed );
|
||||
$rnd_value .= sha1($rnd_value);
|
||||
$rnd_value .= sha1($rnd_value . $seed);
|
||||
|
||||
Reference in New Issue
Block a user