Make WordPress Core

Changeset 44727


Ignore:
Timestamp:
02/07/2019 06:03:32 AM (5 years ago)
Author:
pento
Message:

Multisite: After creating a new blog, ensure the blog cache is correctly cleaned up.

Props david.binda, spacedmonkey.
Fixes #46125.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-site.php

    r44472 r44727  
    724724    );
    725725
     726    // Clean blog cache after populating options.
     727    clean_blog_cache( $site );
     728
    726729    // Populate the site's roles.
    727730    populate_roles();
  • trunk/tests/phpunit/tests/multisite/site.php

    r43655 r44727  
    23212321            return $args;
    23222322        }
     2323
     2324        /**
     2325         * @ticket 46125
     2326         */
     2327        public function test_wpmu_create_blog_cache_cleanup_backward_compatible() {
     2328            add_action( 'populate_options', array( $this, 'populate_options_callback' ) );
     2329
     2330            $blog_id = wpmu_create_blog( 'testsite1.example.org', '/test', 'test', 1, array( 'public' => 1 ), 2 );
     2331
     2332            // Should not hit blog_details cache initialised in $this->populate_options_callback tirggered during
     2333            // populate_options callback's call of get_blog_details.
     2334            $this->assertEquals( 'http://testsite1.example.org/test', get_blog_details( $blog_id )->siteurl );
     2335            $this->assertEquals( 'http://testsite1.example.org/test', get_site( $blog_id )->siteurl );
     2336
     2337            remove_action( 'populate_options', array( $this, 'populate_options_callback' ) );
     2338        }
     2339
     2340        /**
     2341         * Populate options callback to warm cache for blog-details / site-details cache group
     2342         */
     2343        public function populate_options_callback() {
     2344            // Cache blog details
     2345            $blog_id = get_current_blog_id();
     2346            get_blog_details( $blog_id );
     2347            get_site( $blog_id )->siteurl;
     2348            // Set siteurl
     2349            update_option( 'siteurl', 'http://testsite1.example.org/test' );
     2350        }
    23232351    }
    23242352
Note: See TracChangeset for help on using the changeset viewer.