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. git-svn-id: https://develop.svn.wordpress.org/trunk@32626 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
556ffa235a
commit
9560fbdd77
@ -1175,9 +1175,9 @@ function get_blogs_of_user( $user_id, $all = false ) {
|
||||
'path' => $blog->path,
|
||||
'site_id' => $blog->site_id,
|
||||
'siteurl' => $blog->siteurl,
|
||||
'archived' => 0,
|
||||
'spam' => 0,
|
||||
'deleted' => 0
|
||||
'archived' => $blog->archived,
|
||||
'spam' => $blog->spam,
|
||||
'deleted' => $blog->deleted,
|
||||
);
|
||||
}
|
||||
unset( $keys[ $wpdb->base_prefix . 'capabilities' ] );
|
||||
@ -1204,9 +1204,9 @@ function get_blogs_of_user( $user_id, $all = false ) {
|
||||
'path' => $blog->path,
|
||||
'site_id' => $blog->site_id,
|
||||
'siteurl' => $blog->siteurl,
|
||||
'archived' => 0,
|
||||
'spam' => 0,
|
||||
'deleted' => 0
|
||||
'archived' => $blog->archived,
|
||||
'spam' => $blog->spam,
|
||||
'deleted' => $blog->deleted,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -91,9 +91,15 @@ class Tests_Multisite_User extends WP_UnitTestCase {
|
||||
update_blog_details( $blog_ids[2], array( 'deleted' => 1 ) );
|
||||
|
||||
// Passing true as the second parameter should retrieve ALL sites, even if marked.
|
||||
$blog_ids_of_user = array_keys( get_blogs_of_user( $user1_id, true ) );
|
||||
$blogs_of_user = get_blogs_of_user( $user1_id, true );
|
||||
$blog_ids_of_user = array_keys( $blogs_of_user );
|
||||
$this->assertEquals( $blog_ids, $blog_ids_of_user );
|
||||
|
||||
// Check if sites are flagged as expected.
|
||||
$this->assertEquals( 1, $blogs_of_user[ $blog_ids[0] ]->spam );
|
||||
$this->assertEquals( 1, $blogs_of_user[ $blog_ids[1] ]->archived );
|
||||
$this->assertEquals( 1, $blogs_of_user[ $blog_ids[2] ]->deleted );
|
||||
|
||||
unset( $blog_ids[0] );
|
||||
unset( $blog_ids[1] );
|
||||
unset( $blog_ids[2] );
|
||||
|
Loading…
Reference in New Issue
Block a user