Ticket #19571: 19571.diff
File 19571.diff, 1.3 KB (added by , 13 years ago) |
---|
-
wp-includes/pluggable.php
1505 1505 endif; 1506 1506 1507 1507 if ( !function_exists('wp_rand') ) : 1508 1508 /** 1509 1509 * Generates a random number 1510 1510 * 1511 1511 * @since 2.6.2 1512 1512 * 1513 * @param int $min Lower limit for the generated number (optional, default is 0)1514 * @param int $max Upper limit for the generated number (optional, default is 4294967295)1513 * @param int $min Lower limit for the generated number 1514 * @param int $max Upper limit for the generated number 1515 1515 * @return int A random number between min and max 1516 1516 */ 1517 1517 function wp_rand( $min = 0, $max = 0 ) { … … 1540 1540 1541 1541 $value = abs(hexdec($value)); 1542 1542 1543 // Some misconfigured 32bit environments (Etropy PHP, for example) truncate integers larger than PHP_INT_MAX to PHP_INT_MAX rather than overflowing them to floats. 1544 $max_random_number = 3000000000 === 2147483647 ? (float) "4294967295" : 4294967295; // 4294967295 = 0xffffffff 1545 1543 1546 // Reduce the value to be within the min - max range 1544 // 4294967295 = 0xffffffff = max random number1545 1547 if ( $max != 0 ) 1546 $value = $min + ( ($max - $min + 1) * ($value / (4294967295 + 1)));1548 $value = $min + ( $max - $min + 1 ) * $value / ( $max_random_number + 1 ); 1547 1549 1548 1550 return abs(intval($value)); 1549 1551 }