From 1b2926ba6804bd056ab9e20230de5d6b063d8107 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Sun, 27 Sep 2026 12:43:45 +0530 Subject: [PATCH 1/4] Code Quality:Remove resolved identical.alwaysFalse PHPStan baseline: --- src/wp-includes/html-api/class-wp-html-processor.php | 5 +---- src/wp-includes/pluggable.php | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/html-api/class-wp-html-processor.php b/src/wp-includes/html-api/class-wp-html-processor.php index dd4469d5277d9..884d2756b9769 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -1079,10 +1079,7 @@ public function step( $node_to_process = self::PROCESS_NEXT_NODE ): bool { try { $bookmark_name = $this->bookmark_token(); } catch ( Exception $e ) { - if ( self::ERROR_EXCEEDED_MAX_BOOKMARKS === $this->last_error ) { - return false; - } - throw $e; + return false; } $this->state->current_token = new WP_HTML_Token( diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index 0aaeabbb3b9c0..47ded5a5af02d 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -3024,7 +3024,7 @@ function wp_rand( $min = null, $max = null ) { * Some misconfigured 32-bit environments (Entropy PHP, for example) * truncate integers larger than PHP_INT_MAX to PHP_INT_MAX rather than overflowing them to floats. */ - $max_random_number = 3000000000 === 2147483647 ? (float) '4294967295' : 4294967295; // 4294967295 = 0xffffffff + $max_random_number = PHP_INT_SIZE === 4 ? (float) '4294967295' : 4294967295; // 4294967295 = 0xffffffff if ( null === $min ) { $min = 0; From 59dd1a66e34d8056027e9e9d2b411e7dccd7acdf Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Sat, 21 Nov 2026 09:54:43 +0530 Subject: [PATCH 2/4] Remove resolved identical.alwaysFalse PHPStan baseline --- phpstan.neon.dist | 2 +- .../baselines/identical.alwaysFalse.neon | 25 ------------------- 2 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 tests/phpstan/baselines/identical.alwaysFalse.neon diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 796646255ada6..489956d2e056d 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -168,5 +168,5 @@ parameters: # blocks of step() can never match, when in fact they do whenever bookmarks run out. message: '#^Strict comparison using \=\=\= between ''exceeded\-max…'' and null will always evaluate to false\.$#' identifier: identical.alwaysFalse - count: 2 + count: 1 path: src/wp-includes/html-api/class-wp-html-processor.php diff --git a/tests/phpstan/baselines/identical.alwaysFalse.neon b/tests/phpstan/baselines/identical.alwaysFalse.neon deleted file mode 100644 index 0d305bff88893..0000000000000 --- a/tests/phpstan/baselines/identical.alwaysFalse.neon +++ /dev/null @@ -1,25 +0,0 @@ -# PHPStan baseline for the `identical.alwaysFalse` errors in WordPress core. -# -# https://phpstan.org/error-identifiers/identical.alwaysFalse -# -# Each entry is scoped to a single file and carries an exact occurrence count, -# so that a new instance is reported as a new error rather than being absorbed -# silently. Fixing an occurrence therefore means decrementing or removing its -# entry here as part of the same change. -# -# The goal is to empty this file and delete it. -# -# Generated by `composer phpstan:baselines`. Do not edit by hand. Regenerate with: -# -# composer phpstan:baselines -- --identifier=identical.alwaysFalse --config=phpstan.neon.dist -# -# This reruns the analysis with the baselines in this directory suppressed, so -# that their errors surface again, and rewrites only this file. - -parameters: - ignoreErrors: - - - message: '#^Strict comparison using \=\=\= between 3000000000 and 2147483647 will always evaluate to false\.$#' - identifier: identical.alwaysFalse - count: 1 - path: ../../../src/wp-includes/pluggable.php From 0d33b2c7f1e30f012b26bd509aa35c2693516b91 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 25 Nov 2026 12:06:33 -0800 Subject: [PATCH 3/4] Restore the bookmark exhaustion guard in `WP_HTML_Processor::step()`. The check-and-rethrow in the `catch` around `bookmark_token()` was added deliberately in r61755 so that only bookmark exhaustion is swallowed and any other exception still surfaces. It matches the guard in the second `catch` of `step()`, and PHPStan's report on it is a known false positive already ignored with an explanation in `phpstan.neon.dist`, so that ignore goes back to covering both occurrences. Co-Authored-By: Claude Opus 5.5 (medium effort) Claude-Code-Session-Id: 8c9f232d-63db-4e34-bda9-62a5e32e95a7 --- phpstan.neon.dist | 2 +- src/wp-includes/html-api/class-wp-html-processor.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 489956d2e056d..796646255ada6 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -168,5 +168,5 @@ parameters: # blocks of step() can never match, when in fact they do whenever bookmarks run out. message: '#^Strict comparison using \=\=\= between ''exceeded\-max…'' and null will always evaluate to false\.$#' identifier: identical.alwaysFalse - count: 1 + count: 2 path: src/wp-includes/html-api/class-wp-html-processor.php diff --git a/src/wp-includes/html-api/class-wp-html-processor.php b/src/wp-includes/html-api/class-wp-html-processor.php index 884d2756b9769..dd4469d5277d9 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -1079,7 +1079,10 @@ public function step( $node_to_process = self::PROCESS_NEXT_NODE ): bool { try { $bookmark_name = $this->bookmark_token(); } catch ( Exception $e ) { - return false; + if ( self::ERROR_EXCEEDED_MAX_BOOKMARKS === $this->last_error ) { + return false; + } + throw $e; } $this->state->current_token = new WP_HTML_Token( From a7b4eeadf8520c68e2ee0ed142733e64e2d7b6c8 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 25 Nov 2026 12:07:26 -0800 Subject: [PATCH 4/4] 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) Claude-Code-Session-Id: 8c9f232d-63db-4e34-bda9-62a5e32e95a7 --- src/wp-includes/pluggable.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index c1b1059a2db23..46995a9e8a5d1 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -3054,8 +3054,9 @@ function wp_rand( $min = null, $max = null ) { global $rnd_value; /* - * Some misconfigured 32-bit environments (Entropy PHP, for example) - * truncate integers larger than PHP_INT_MAX to PHP_INT_MAX rather than overflowing them to floats. + * On 32-bit systems, 0xffffffff exceeds PHP_INT_MAX, so it is cast to a float explicitly. + * Some misconfigured 32-bit environments (Entropy PHP, for example) truncate integer literals + * larger than PHP_INT_MAX to PHP_INT_MAX rather than overflowing them to floats. */ $max_random_number = PHP_INT_SIZE === 4 ? (float) '4294967295' : 4294967295; // 4294967295 = 0xffffffff