Ticket #6577: 6577.user_ids.patch
| File 6577.user_ids.patch, 2.2 KB (added by , 11 years ago) |
|---|
-
src/bp-core/classes/class-bp-user-query.php
595 595 } 596 596 597 597 // Match up to the user ids from the main query 598 foreach ( $this->user_ids as $ uid ) {598 foreach ( $this->user_ids as $key => $uid ) { 599 599 if ( isset( $r[ $uid ] ) ) { 600 600 $this->results[ $uid ] = $r[ $uid ]; 601 601 602 602 // The BP template functions expect an 'id' 603 603 // (as opposed to 'ID') property 604 604 $this->results[ $uid ]->id = $uid; 605 606 // remove user ID from original user_ids property 607 } else { 608 unset( $this->user_ids[ $key ] ); 605 609 } 606 610 } 607 611 } -
src/bp-friends/bp-friends-filters.php
60 60 if ( bp_loggedin_user_id() == $nf ) { 61 61 continue; 62 62 } 63 $user_query->results[ $nf ]->friendship_status = 'not_friends'; 63 64 if ( isset( $user_query->results[ $nf ] ) ) { 65 $user_query->results[ $nf ]->friendship_status = 'not_friends'; 66 } 64 67 } 65 68 66 69 } -
tests/phpunit/testcases/core/class-bp-user-query.php
66 66 $this->assertEquals( $friend_ids, array() ); 67 67 } 68 68 69 /** 70 * @group user_ids 71 */ 72 public function test_bp_user_query_user_ids_with_invalid_user_id() { 73 $now = time(); 74 $u1 = $this->factory->user->create(); 75 $u2 = $this->factory->user->create(); 76 77 // invalid user ID 78 $u3 = $u2 + 1; 79 80 $old_user = get_current_user_id(); 81 $this->set_current_user( $u1 ); 82 83 // pass 'user_ids' to user query to trigger this bug 84 $q = new BP_User_Query( array( 85 'user_ids' => array( $u2, $u3 ) 86 ) ); 87 88 // $q->user_ids property should now not contain invalid user IDs 89 $this->assertNotContains( $u3, $q->user_ids ); 90 91 // clean up 92 $this->set_current_user( $old_user ); 93 } 94 69 95 public function test_bp_user_query_sort_by_popular() { 70 96 $u1 = $this->factory->user->create(); 71 97 $u2 = $this->factory->user->create();