From cab8d7df1a14f5dee699ef18543a418c9cdc304b Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Mon, 18 Mar 2019 15:47:36 +0000 Subject: [PATCH] Multisite: Ensure site meta caches are not primed unless the `wp_blogmeta` table is available. Prior to this change, querying sites early in the bootstrap process could potentially cause a fatal error, since at that stage the filter to bail on updating site meta cache if the respective database table has not been installed yet is not hooked in yet. This changeset forces the filter to be added if that is not already the case. Props spacedmonkey. Fixes #46167. git-svn-id: https://develop.svn.wordpress.org/trunk@44925 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/ms-site.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wp-includes/ms-site.php b/src/wp-includes/ms-site.php index 920e5d8b37..2d568a57f5 100644 --- a/src/wp-includes/ms-site.php +++ b/src/wp-includes/ms-site.php @@ -380,6 +380,10 @@ function update_site_cache( $sites, $update_meta_cache = true ) { * @return array|false Returns false if there is nothing to update. Returns an array of metadata on success. */ function update_sitemeta_cache( $site_ids ) { + // Ensure this filter is hooked in even if the function is called early. + if ( ! has_filter( 'update_blog_metadata_cache', 'wp_check_site_meta_support_prefilter' ) ) { + add_filter( 'update_blog_metadata_cache', 'wp_check_site_meta_support_prefilter' ); + } return update_meta_cache( 'blog', $site_ids ); }