Skip to content

Cast $blog_id to int in wp_cache_clear_cache()#1054

Merged
donnchawp merged 1 commit into
trunkfrom
fix/1019-blog-id-cast
May 27, 2026
Merged

Cast $blog_id to int in wp_cache_clear_cache()#1054
donnchawp merged 1 commit into
trunkfrom
fix/1019-blog-id-cast

Conversation

@donnchawp
Copy link
Copy Markdown
Contributor

Fixes #1019.

Some third-party callers invoke wp_cache_clear_cache() with a non-integer first argument (e.g. wp_cache_clear_cache('all', false)). That value flows into get_supercache_dir() -> get_blog_option(), a multisite-only function, which fatals on single-site installs.

Casting $blog_id to int normalizes 'all'/false to 0, so those calls take the single-site clearing path. Legitimate integer blog IDs are unaffected.

Note: PR #1042 also contains this cast (bundled with the #1016 fclose fix and two redundant guards). This PR isolates just the #1019 fix.

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.
@donnchawp donnchawp merged commit ed5d373 into trunk May 27, 2026
6 checks passed
@donnchawp donnchawp mentioned this pull request May 27, 2026
@donnchawp donnchawp deleted the fix/1019-blog-id-cast branch May 27, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant