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
This commit is contained in:
Scott Taylor 2014-06-28 04:07:16 +00:00
parent 13d0a45932
commit 2e81419d4c
2 changed files with 17 additions and 1 deletions

View File

@ -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.
*

View File

@ -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' );