Skip to content

Fix: cast $blog_id to int in wp_cache_clear_cache() to prevent crash on non-multisite installs#1042

Open
DeveloperBatuhanALGUL wants to merge 1 commit into
Automattic:trunkfrom
DeveloperBatuhanALGUL:fix/wp-cache-clear-cache-blog-id-type
Open

Fix: cast $blog_id to int in wp_cache_clear_cache() to prevent crash on non-multisite installs#1042
DeveloperBatuhanALGUL wants to merge 1 commit into
Automattic:trunkfrom
DeveloperBatuhanALGUL:fix/wp-cache-clear-cache-blog-id-type

Conversation

@DeveloperBatuhanALGUL
Copy link
Copy Markdown

Problem

When a third-party theme or plugin calls wp_cache_clear_cache('all', false) with a non-integer $blog_id, the function passes that value directly to get_supercache_dir(), which internally calls get_blog_option() — a multisite-only function. On non-multisite installs, this causes a fatal error.

Fixes #1019

Fix

Cast $blog_id to int at the top of the function. This ensures any non-integer value (e.g. 'all', false) is normalized to 0, which correctly triggers the single-site cache clearing path.

Testing

  1. On a non-multisite WordPress install, call wp_cache_clear_cache('all', false)
  2. Confirm no fatal error occurs and cache is cleared correctly

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