Make WordPress Core

Changeset 32626


Ignore:
Timestamp:
05/27/2015 09:22:09 PM (10 years ago)
Author:
jeremyfelt
Message:

Provide all site flag data in objects returned by get_blogs_of_user()

Previously, archived, spam, and deleted properties were forced to 0 when returned by get_blogs_of_user(). This was originally introduced in [21794] as a way to prevent notices when properties were expected.

Instead, we can properly fill these properties with those retrieved from get_blog_details().

Props realloc.
Fixes #32281.

Location:
trunk
Files:
2 edited

Legend:

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

    r32541 r32626  
    11761176                'site_id'     => $blog->site_id,
    11771177                'siteurl'     => $blog->siteurl,
    1178                 'archived'    => 0,
    1179                 'spam'        => 0,
    1180                 'deleted'     => 0
     1178                'archived'    => $blog->archived,
     1179                'spam'        => $blog->spam,
     1180                'deleted'     => $blog->deleted,
    11811181            );
    11821182        }
     
    12051205                'site_id'     => $blog->site_id,
    12061206                'siteurl'     => $blog->siteurl,
    1207                 'archived'    => 0,
    1208                 'spam'        => 0,
    1209                 'deleted'     => 0
     1207                'archived'    => $blog->archived,
     1208                'spam'        => $blog->spam,
     1209                'deleted'     => $blog->deleted,
    12101210            );
    12111211        }
  • trunk/tests/phpunit/tests/user/multisite.php

    r31623 r32626  
    9292
    9393        // Passing true as the second parameter should retrieve ALL sites, even if marked.
    94         $blog_ids_of_user = array_keys( get_blogs_of_user( $user1_id, true ) );
    95         $this->assertEquals( $blog_ids, $blog_ids_of_user );
     94        $blogs_of_user = get_blogs_of_user( $user1_id, true );
     95        $blog_ids_of_user = array_keys( $blogs_of_user );
     96        $this->assertEquals( $blog_ids, $blog_ids_of_user );
     97
     98        // Check if sites are flagged as expected.
     99        $this->assertEquals( 1, $blogs_of_user[ $blog_ids[0] ]->spam );
     100        $this->assertEquals( 1, $blogs_of_user[ $blog_ids[1] ]->archived );
     101        $this->assertEquals( 1, $blogs_of_user[ $blog_ids[2] ]->deleted );
    96102
    97103        unset( $blog_ids[0] );
Note: See TracChangeset for help on using the changeset viewer.