From d6b79f6250c95e4191e265eee5e11bdbd191e804 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sat, 14 Mar 2026 19:23:49 +0000 Subject: [PATCH] Cache API: Address code quality issues with `wp_cache_switch_to_blog()`. This addresses 3 PHPStan errors at rule level 8: * `arguments.count`: Function `wp_cache_switch_to_blog_fallback()` invoked with 1 parameter, 0 required. * `method.nonObject`: Cannot call method `switch_to_blog()` on `class-string|object`. * `missingType.return`: Function `wp_cache_switch_to_blog()` has no return type specified. Developed as subset of https://github.com/WordPress/wordpress-develop/pull/11151 Follow-up to r61760. Props westonruter, johnjamesjacoby. See #23290, #64238. Built from https://develop.svn.wordpress.org/trunk@62028 git-svn-id: http://core.svn.wordpress.org/trunk@61310 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/cache-compat.php | 6 +++--- wp-includes/version.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wp-includes/cache-compat.php b/wp-includes/cache-compat.php index fe0e29c107..6f8842ab04 100644 --- a/wp-includes/cache-compat.php +++ b/wp-includes/cache-compat.php @@ -327,11 +327,11 @@ if ( ! function_exists( 'wp_cache_switch_to_blog' ) ) : * * @param int $blog_id Site ID. */ - function wp_cache_switch_to_blog( $blog_id ) { + function wp_cache_switch_to_blog( $blog_id ): void { global $wp_object_cache; // Attempt to use the drop-in object cache method if it exists. - if ( method_exists( $wp_object_cache, 'switch_to_blog' ) ) { + if ( is_object( $wp_object_cache ) && method_exists( $wp_object_cache, 'switch_to_blog' ) ) { $wp_object_cache->switch_to_blog( $blog_id ); return; } @@ -340,6 +340,6 @@ if ( ! function_exists( 'wp_cache_switch_to_blog' ) ) : * Perform a fallback blog switch, which will reinitialize the caches * for the new blog ID. */ - wp_cache_switch_to_blog_fallback( $blog_id ); + wp_cache_switch_to_blog_fallback(); } endif; diff --git a/wp-includes/version.php b/wp-includes/version.php index 37b543fc6b..a0151ad9be 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '7.0-beta5-62027'; +$wp_version = '7.0-beta5-62028'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.