Skip to content

Commit ed5d373

Browse files
authored
Cast $blog_id to int in wp_cache_clear_cache() (#1054)
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.
1 parent 1c6e7e2 commit ed5d373

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

wp-cache-phase2.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3089,6 +3089,10 @@ function wp_cache_clear_cache_on_menu() {
30893089
function wp_cache_clear_cache( $blog_id = 0 ) {
30903090
global $cache_path;
30913091

3092+
// Normalize non-integer callers (e.g. 'all', false) to 0 so they take the
3093+
// single-site path instead of reaching get_blog_option() via the blog branch.
3094+
$blog_id = (int) $blog_id;
3095+
30923096
if ( $blog_id == 0 ) {
30933097
wp_cache_debug( 'Clearing all cached files in wp_cache_clear_cache()', 4 );
30943098
prune_super_cache( $cache_path . 'supercache/', true );

0 commit comments

Comments
 (0)