Commit 32845e4059 for wordpress.org

commit 32845e40595e4c684dd1047903e182141f539224
Author: westonruter <westonruter@git.wordpress.org>
Date:   Wed Nov 25 18:35:55 2026 +0000

    Code Quality: Resolve the notIdentical.alwaysTrue PHPStan errors.

    In `wp_timezone_choice()` the `'Etc' !== $zone[0]` check has always been true since `Etc` was removed from the list of continents in r12507, because zones outside that list are skipped before the check is reached.

    In `wp_rand()` the `false !== $val` check after calling `random_int()` was added in r34981, while PHP 7 was still in release candidates whose `random_int()` had only just switched from returning `false` on failure to throwing an exception. Stable PHP 7.0 shipped with the exception, and the bundled `random_compat` polyfill always threw, so the check could never fail. Since r56141 raised the minimum PHP version and removed the polyfill, the existing `catch` blocks are what fall back to the internal generator, so behavior is unchanged. Removing the two checks empties the baseline, so it is removed.

    Additionally, `wp_rand()` now passes PHPStan level 10. Its return type is narrowed to `non-negative-int`, which both code paths already guarantee, and the seed read with `get_transient()` is reset to an empty string when it is not a string, which keeps the existing behavior for a missing transient whose `false` value was concatenated as an empty string.

    Developed in https://github.com/WordPress/wordpress-develop/pull/14036.
    Follow-up to r11597, r12507, r34981, r56141, r63023.

    Props huzaifaalmesbah, westonruter.
    See #66739.

    Built from https://develop.svn.wordpress.org/trunk@65788


    git-svn-id: http://core.svn.wordpress.org/trunk@64817 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index 9f05a8c592..6d2130c65b 100644
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -6933,7 +6933,7 @@ function wp_timezone_choice( $selected_zone, $locale = null ) {
 			1 => ! empty( $zone[1] ),
 			2 => ! empty( $zone[2] ),
 		);
-		$exists[3] = ( $exists[0] && 'Etc' !== $zone[0] );
+		$exists[3] = $exists[0];
 		$exists[4] = ( $exists[1] && $exists[3] );
 		$exists[5] = ( $exists[2] && $exists[3] );

diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php
index 30fa4b9814..76198dcbd8 100644
--- a/wp-includes/pluggable.php
+++ b/wp-includes/pluggable.php
@@ -3047,6 +3047,8 @@ if ( ! function_exists( 'wp_rand' ) ) :
 	 * @param int $max Optional. Upper limit for the generated number.
 	 *                 Accepts positive integers. Defaults to 4294967295.
 	 * @return int A random non-negative number between min and max.
+	 *
+	 * @phpstan-return non-negative-int
 	 */
 	function wp_rand( $min = null, $max = null ) {
 		global $rnd_value;
@@ -3077,11 +3079,7 @@ if ( ! function_exists( 'wp_rand' ) ) :
 				$_max = max( $min, $max );
 				$_min = min( $min, $max );
 				$val  = random_int( $_min, $_max );
-				if ( false !== $val ) {
-					return absint( $val );
-				} else {
-					$use_random_int_functionality = false;
-				}
+				return absint( $val );
 			} catch ( Error $e ) {
 				$use_random_int_functionality = false;
 			} catch ( Exception $e ) {
@@ -3095,9 +3093,13 @@ if ( ! function_exists( 'wp_rand' ) ) :
 		 */
 		if ( strlen( $rnd_value ) < 8 ) {
 			if ( defined( 'WP_SETUP_CONFIG' ) ) {
+				/** @var string $seed */
 				static $seed = '';
 			} else {
 				$seed = get_transient( 'random_seed' );
+				if ( ! is_string( $seed ) ) {
+					$seed = '';
+				}
 			}
 			$rnd_value  = md5( uniqid( microtime() . mt_rand(), true ) . $seed );
 			$rnd_value .= sha1( $rnd_value );
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 14c649c175..071d31e564 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.3-alpha-65787';
+$wp_version = '7.3-alpha-65788';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.