Skip to content

Commit a7b4eea

Browse files
westonruterclaude
andcommitted
Update the wp_rand() comment for the PHP_INT_SIZE check.
The comment described detecting integer truncation, which the ternary no longer does. It now explains that 0xffffffff is cast to a float on every 32-bit system, with the misconfigured environments as the reason the cast is explicit rather than left to integer overflow. Co-Authored-By: Claude Opus 5.5 (medium effort) <noreply@anthropic.com> Claude-Code-Session-Id: 8c9f232d-63db-4e34-bda9-62a5e32e95a7
1 parent 0d33b2c commit a7b4eea

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎src/wp-includes/pluggable.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3054,8 +3054,9 @@ function wp_rand( $min = null, $max = null ) {
30543054
global $rnd_value;
30553055

30563056
/*
3057-
* Some misconfigured 32-bit environments (Entropy PHP, for example)
3058-
* truncate integers larger than PHP_INT_MAX to PHP_INT_MAX rather than overflowing them to floats.
3057+
* On 32-bit systems, 0xffffffff exceeds PHP_INT_MAX, so it is cast to a float explicitly.
3058+
* Some misconfigured 32-bit environments (Entropy PHP, for example) truncate integer literals
3059+
* larger than PHP_INT_MAX to PHP_INT_MAX rather than overflowing them to floats.
30593060
*/
30603061
$max_random_number = PHP_INT_SIZE === 4 ? (float) '4294967295' : 4294967295; // 4294967295 = 0xffffffff
30613062

0 commit comments

Comments
 (0)