[buddypress-trac] [BuddyPress Trac] #7248: include = [ 0 ] should result in a "no results" query in `BP_User_Query`
buddypress-trac
noreply at wordpress.org
Tue Sep 6 15:39:39 UTC 2016
#7248: include = [ 0 ] should result in a "no results" query in `BP_User_Query`
--------------------------+-------------------------
Reporter: boonebgorges | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 2.7
Component: Core | Version:
Severity: normal | Keywords: needs-patch
--------------------------+-------------------------
A client site just ran into MySQL issues because of a bit of code that was
occasionally doing queries like this:
{{{
$include_ids = run_some_function_to_get_include_ids();
// Ensure that an empty $include_ids doesn't return any results
if ( empty( $include_ids ) ) {
$include_ids = array( 0 );
}
if ( bp_has_members( array( 'include' => $include_ids ) ) {
// ...
}
}}}
Because user_id is never 0, MySQL is forced to scan the entire table just
to return no results. This takes a very long time in some cases. Since we
know that there will be no results, we should bail early in this special
case (with 0=1).
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7248>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list