Make WordPress Core

Ticket #26410: 26410.diff

File 26410.diff, 1.9 KB (added by kovshenin, 11 years ago)
  • src/wp-includes/ms-blogs.php

     
    264264}
    265265
    266266/**
     267 * Refresh blog details when an option is updated.
     268 *
     269 * @access private
     270 */
     271function _wp_refresh_blog_details_on_updated_option( $option_name ) {
     272        $options = array( 'blogname', 'siteurl', 'post_count' );
     273        if ( in_array( $option_name, $options ) ) {
     274                refresh_blog_details( get_current_blog_id() );
     275        }
     276}
     277
     278/**
    267279 * Update the details for a blog. Updates the blogs table for a given blog id.
    268280 *
    269281 * @since MU
  • src/wp-includes/ms-default-filters.php

     
    6969remove_filter( 'option_siteurl', '_config_wp_siteurl' );
    7070remove_filter( 'option_home',    '_config_wp_home'    );
    7171
     72// Some options changes should trigger blog details refresh.
     73add_action( 'updated_option', '_wp_refresh_blog_details_on_updated_option' );
     74
    7275// If the network upgrade hasn't run yet, assume ms-files.php rewriting is used.
    7376add_filter( 'default_site_option_ms_files_rewriting', '__return_true' );
    7477
  • tests/phpunit/tests/ms.php

     
    13851385                        $GLOBALS['super_admins'] = $old_global;
    13861386                }
    13871387        }
     1388
     1389        /**
     1390         * @ticket 26410
     1391         */
     1392        function test_blog_details_cache_invalidation() {
     1393                update_option( 'blogname', 'foo' );
     1394                $details = get_blog_details( get_current_blog_id() );
     1395                $this->assertEquals( 'foo', $details->blogname );
     1396
     1397                update_option( 'blogname', 'bar' );
     1398                $details = get_blog_details( get_current_blog_id() );
     1399                $this->assertEquals( 'bar', $details->blogname );
     1400        }
    13881401}
    13891402
    13901403endif;