From 2e81419d4cef819fdcdf591f03bd87bfcdb449bb Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sat, 28 Jun 2014 04:07:16 +0000 Subject: [PATCH] In multisite, on the `updated_option` action, if the option name is one of: 'blogname', 'siteurl', 'post_count' - refresh the blog details cache for the current blog id. Adds unit test. Props kovshenin. Fixes #26410. Built from https://develop.svn.wordpress.org/trunk@28881 git-svn-id: http://core.svn.wordpress.org/trunk@28680 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/ms-blogs.php | 15 ++++++++++++++- wp-includes/ms-default-filters.php | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/wp-includes/ms-blogs.php b/wp-includes/ms-blogs.php index 8aa702a937..6a14febc3a 100644 --- a/wp-includes/ms-blogs.php +++ b/wp-includes/ms-blogs.php @@ -263,6 +263,19 @@ function refresh_blog_details( $blog_id ) { do_action( 'refresh_blog_details', $blog_id ); } +/** + * Refresh blog details when an option is updated. + * + * @access private + * @param string $option_name + */ +function _wp_refresh_blog_details_on_updated_option( $option_name ) { + $options = array( 'blogname', 'siteurl', 'post_count' ); + if ( in_array( $option_name, $options ) ) { + refresh_blog_details( get_current_blog_id() ); + } +} + /** * Update the details for a blog. Updates the blogs table for a given blog id. * @@ -903,7 +916,7 @@ function _update_posts_count_on_delete( $post_id ) { if ( 'publish' !== get_post_field( 'post_status', $post_id ) ) { return; } - + update_posts_count(); } diff --git a/wp-includes/ms-default-filters.php b/wp-includes/ms-default-filters.php index 00b3bda982..3b22b87e1b 100644 --- a/wp-includes/ms-default-filters.php +++ b/wp-includes/ms-default-filters.php @@ -70,6 +70,9 @@ add_filter( 'force_filtered_html_on_import', '__return_true' ); remove_filter( 'option_siteurl', '_config_wp_siteurl' ); remove_filter( 'option_home', '_config_wp_home' ); +// Some options changes should trigger blog details refresh. +add_action( 'updated_option', '_wp_refresh_blog_details_on_updated_option' ); + // If the network upgrade hasn't run yet, assume ms-files.php rewriting is used. add_filter( 'default_site_option_ms_files_rewriting', '__return_true' );