Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/wp-includes/ms-blogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ function get_blog_details( $fields = null, $get_all = true ) {
$details = wp_cache_get( $blog_id . 'short', 'blog-details' );
} else {
$details = wp_cache_get( $blog_id, 'blog-details' );
// If short was requested and full cache is set, we can return.
if ( $details ) {
if ( ! is_object( $details ) ) {
if ( -1 === $details ) {
Expand All @@ -220,7 +219,9 @@ function get_blog_details( $fields = null, $get_all = true ) {
unset( $details );
}
} else {
return $details;
// Full cache is set but short was requested. Discard so a clean
// short result is built from WP_Site::get_instance() below.
unset( $details );
}
}
}
Expand Down
42 changes: 42 additions & 0 deletions tests/phpunit/tests/multisite/getBlogDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,48 @@ public function test_get_blog_details_iterate_over_result( $get_all ) {
$this->assertSameSets( $this->get_fields( $get_all ), $result );
}

/**
* @ticket 63518
*/
public function test_get_blog_details_get_all_true_then_false_returns_short() {
$site_id = self::$site_ids['wordpress.org/'];

// Ensure a clean cache state.
wp_cache_delete( $site_id, 'blog-details' );
wp_cache_delete( $site_id . 'short', 'blog-details' );

// Populate the full cache first.
$full = get_blog_details( $site_id, true );
$this->assertSameSets( $this->get_fields( true ), array_keys( get_object_vars( $full ) ) );

// A subsequent short request must not return the full result.
$short = get_blog_details( $site_id, false );
$this->assertSameSets( $this->get_fields( false ), array_keys( get_object_vars( $short ) ) );
}

/**
* @ticket 63518
*/
public function test_get_blog_details_false_true_false_returns_correct_fields() {
$site_id = self::$site_ids['wordpress.org/'];

// Ensure a clean cache state.
wp_cache_delete( $site_id, 'blog-details' );
wp_cache_delete( $site_id . 'short', 'blog-details' );

// Short first.
$short1 = get_blog_details( $site_id, false );
$this->assertSameSets( $this->get_fields( false ), array_keys( get_object_vars( $short1 ) ) );

// Full second.
$full = get_blog_details( $site_id, true );
$this->assertSameSets( $this->get_fields( true ), array_keys( get_object_vars( $full ) ) );

// Short again — must still return short fields.
$short2 = get_blog_details( $site_id, false );
$this->assertSameSets( $this->get_fields( false ), array_keys( get_object_vars( $short2 ) ) );
}

public function data_get_all() {
return array(
array( false ),
Expand Down
Loading