Skip to content

Commit ebbe91a

Browse files
committed
Revert [34922] pending PHP 5.2 compatibility.
See #28633 git-svn-id: https://develop.svn.wordpress.org/trunk@34924 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 6cc5757 commit ebbe91a

10 files changed

Lines changed: 3 additions & 854 deletions

src/wp-includes/compat.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,3 @@ interface JsonSerializable {
332332
public function jsonSerialize();
333333
}
334334
}
335-
336-
// random_int was introduced in PHP 7.0
337-
if ( ! function_exists( 'random_int' ) ) {
338-
require ABSPATH . WPINC . '/random_compat/random.php';
339-
}

src/wp-includes/pluggable.php

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,11 +2132,9 @@ function wp_generate_password( $length = 12, $special_chars = true, $extra_speci
21322132
* Generates a random number
21332133
*
21342134
* @since 2.6.2
2135-
* @since 4.4 Uses PHP7 random_int() or the random_compat library if avaialble.
21362135
*
21372136
* @global string $rnd_value
21382137
* @staticvar string $seed
2139-
* @staticvar bool $external_rand_source_available
21402138
*
21412139
* @param int $min Lower limit for the generated number
21422140
* @param int $max Upper limit for the generated number
@@ -2145,34 +2143,6 @@ function wp_generate_password( $length = 12, $special_chars = true, $extra_speci
21452143
function wp_rand( $min = 0, $max = 0 ) {
21462144
global $rnd_value;
21472145

2148-
// Some misconfigured 32bit environments (Entropy PHP, for example) truncate integers larger than PHP_INT_MAX to PHP_INT_MAX rather than overflowing them to floats.
2149-
$max_random_number = 3000000000 === 2147483647 ? (float) "4294967295" : 4294967295; // 4294967295 = 0xffffffff
2150-
2151-
// We only handle Ints, floats are truncated to their integer value.
2152-
$min = (int) $min;
2153-
$max = (int) $max;
2154-
2155-
// Use PHP's CSPRNG, or a compatible method
2156-
static $use_random_int_functionality = true;
2157-
if ( $use_random_int_functionality ) {
2158-
try {
2159-
$_max = ( 0 != $max ) ? $max : $max_random_number;
2160-
// wp_rand() can accept arguements in either order, PHP cannot.
2161-
$_max = max( $min, $_max );
2162-
$_min = min( $min, $_max );
2163-
$val = random_int( $_min, $_max );
2164-
if ( false !== $val ) {
2165-
return absint( $val );
2166-
} else {
2167-
$use_random_int_functionality = false;
2168-
}
2169-
} catch ( Throwable $t ) {
2170-
$use_random_int_functionality = false;
2171-
} catch ( Exception $e ) {
2172-
$use_random_int_functionality = false;
2173-
}
2174-
}
2175-
21762146
// Reset $rnd_value after 14 uses
21772147
// 32(md5) + 40(sha1) + 40(sha1) / 8 = 14 random numbers from $rnd_value
21782148
if ( strlen($rnd_value) < 8 ) {
@@ -2197,6 +2167,9 @@ function wp_rand( $min = 0, $max = 0 ) {
21972167

21982168
$value = abs(hexdec($value));
21992169

2170+
// Some misconfigured 32bit environments (Entropy PHP, for example) truncate integers larger than PHP_INT_MAX to PHP_INT_MAX rather than overflowing them to floats.
2171+
$max_random_number = 3000000000 === 2147483647 ? (float) "4294967295" : 4294967295; // 4294967295 = 0xffffffff
2172+
22002173
// Reduce the value to be within the min - max range
22012174
if ( $max != 0 )
22022175
$value = $min + ( $max - $min + 1 ) * $value / ( $max_random_number + 1 );

src/wp-includes/random_compat/byte_safe_strings.php

Lines changed: 0 additions & 154 deletions
This file was deleted.

src/wp-includes/random_compat/error_polyfill.php

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/wp-includes/random_compat/random.php

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)