Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/11/2015 04:54:03 PM (10 years ago)
Author:
r-a-y
Message:

BP User Query: Remove invalid IDs from $user_ids property after query is run.

If the user_ids parameter is passed to BP_User_Query with invalid user
IDs, after the user query is run, the user_ids property still references
these invalid user IDs. This can lead to devs to assume that the user ID
exists when it does not.

This commit removes these invalid user IDs and includes a unit test.

See #6577.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-user-query.php

    r10012 r10043  
    596596
    597597        // 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 ) {
    599599            if ( isset( $r[ $uid ] ) ) {
    600600                $this->results[ $uid ] = $r[ $uid ];
     
    603603                // (as opposed to 'ID') property
    604604                $this->results[ $uid ]->id = $uid;
     605
     606            // remove user ID from original user_ids property
     607            } else {
     608                unset( $this->user_ids[ $key ] );
    605609            }
    606610        }
Note: See TracChangeset for help on using the changeset viewer.