[wp-trac] [WordPress Trac] #63518: get_blog_details( get_all: false ) not working as expected

WordPress Trac noreply at wordpress.org
Mon Feb 23 16:56:00 UTC 2026


#63518: get_blog_details( get_all: false ) not working as expected
-------------------------------------------------+-------------------------
 Reporter:  apermo                               |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  Networks and Sites                   |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch changes-requested          |     Focuses:  multisite
  reporter-feedback has-unit-tests               |
-------------------------------------------------+-------------------------

Comment (by apermo):

 @debarghyabanerjee @ravigadhiyawp did you try to reproduce on a Multisite?
 I just tried again, and I still can reproduce the issue.

 How to reproduce:

 1. Set up a WordPress multisite environment
 2. Run the following code on any multisite site (e.g. in a mu-plugin or
 via WP-CLI eval):


 {{{#!php
 <?php
 $site_id = get_current_blog_id();

 // Call with $get_all = true first, then false.

 $full  = get_blog_details( $site_id, true );
 $short = get_blog_details( $site_id, false );

 echo "Full fields:\n";
 print_r( array_keys( get_object_vars( $full ) ) );

 echo "Short fields:\n";
 print_r( array_keys( get_object_vars( $short ) ) );
 }}}


 **Expected:**
 The short result should only contain the base site fields (blog_id,
 domain, path, site_id, registered, last_updated, public, archived, mature,
 spam, deleted, lang_id).

 **Actual:**
 The short result incorrectly includes blogname, siteurl, post_count, and
 home — the same fields as the full result.

 **Root cause:**
 In ms-blogs.php, the "Try the other cache" block (around line 212) returns
 the full cached result directly when $get_all = false:

 {{{#!php
 } else {
    return $details; // Returns full result even though short was requested
 }

 }}}


 Fix: Replace that return with unset( $details ) so the code falls through
 to WP_Site::get_instance() (which uses its own sites cache — no extra DB
 query) and builds a clean short result.

 PHPUnit reproduction: The patch includes two multisite tests covering both
 sequences from the ticket description. Run with:

 `npm run test:php -- --configuration=tests/phpunit/multisite.xml
 --filter="test_get_blog_details_(get_all_true_then_false|false_true_false)"`

 Without the fix,
 test_get_blog_details_get_all_true_then_false_returns_short fails. With
 the fix, all 21 getBlogDetails tests pass.

 To see the test, check the pull request I just opened.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63518#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list