From 254e22b04ab480633c9e488ebc07ec992436d04d Mon Sep 17 00:00:00 2001 From: Donncha O Caoimh <5656673+donnchawp@users.noreply.github.com> Date: Wed, 27 May 2026 18:16:19 +0100 Subject: [PATCH] Cast $blog_id to int in wp_cache_clear_cache() Third-party callers sometimes pass a non-integer (e.g. wp_cache_clear_cache('all', false)). The value flows to get_supercache_dir() -> get_blog_option(), a multisite-only function, fataling on single-site installs. Casting to int normalizes 'all'/false to 0, taking the single-site clearing path. Fixes #1019. --- wp-cache-phase2.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wp-cache-phase2.php b/wp-cache-phase2.php index c1369415..a1dc3128 100644 --- a/wp-cache-phase2.php +++ b/wp-cache-phase2.php @@ -3089,6 +3089,10 @@ function wp_cache_clear_cache_on_menu() { function wp_cache_clear_cache( $blog_id = 0 ) { global $cache_path; + // Normalize non-integer callers (e.g. 'all', false) to 0 so they take the + // single-site path instead of reaching get_blog_option() via the blog branch. + $blog_id = (int) $blog_id; + if ( $blog_id == 0 ) { wp_cache_debug( 'Clearing all cached files in wp_cache_clear_cache()', 4 ); prune_super_cache( $cache_path . 'supercache/', true );