Make WordPress Core


Ignore:
Timestamp:
02/07/2019 06:03:32 AM (6 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.