Skip to content

Commit 6f20911

Browse files
committed
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 #11151 Follow-up to r61760. Props westonruter, johnjamesjacoby. See #23290, #64238. git-svn-id: https://develop.svn.wordpress.org/trunk@62028 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 6dac3b4 commit 6f20911

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/wp-includes/cache-compat.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,11 @@ function wp_cache_set_multiple_salted( $data, $group, $salt, $expire = 0 ) {
327327
*
328328
* @param int $blog_id Site ID.
329329
*/
330-
function wp_cache_switch_to_blog( $blog_id ) {
330+
function wp_cache_switch_to_blog( $blog_id ): void {
331331
global $wp_object_cache;
332332

333333
// Attempt to use the drop-in object cache method if it exists.
334-
if ( method_exists( $wp_object_cache, 'switch_to_blog' ) ) {
334+
if ( is_object( $wp_object_cache ) && method_exists( $wp_object_cache, 'switch_to_blog' ) ) {
335335
$wp_object_cache->switch_to_blog( $blog_id );
336336
return;
337337
}
@@ -340,6 +340,6 @@ function wp_cache_switch_to_blog( $blog_id ) {
340340
* Perform a fallback blog switch, which will reinitialize the caches
341341
* for the new blog ID.
342342
*/
343-
wp_cache_switch_to_blog_fallback( $blog_id );
343+
wp_cache_switch_to_blog_fallback();
344344
}
345345
endif;

0 commit comments

Comments
 (0)