Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/30/2015 06:44:55 PM (11 years ago)
Author:
boonebgorges
Message:

Enforce no_results when getting a 0=1 result from the member type tax query.

When passing a 'member_type' to BP_User_Query and no users belong to the
member type, the WP_Tax_Query transformation will return a '0 = 1' clause to
indicate that no results were found. We should respect this result, so that no
members are returned for this kind of query.

Fixes #6334 for the 2.2 branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/src/bp-core/bp-core-classes.php

    r9404 r9663  
    436436                                restore_current_blog();
    437437
    438 
    439 
    440438                                // Grab the first term_relationships clause and convert to a subquery.
    441439                                if ( preg_match( '/' . $wpdb->term_relationships . '\.term_taxonomy_id IN \([0-9, ]+\)/', $member_type_sql_clauses['where'], $matches ) ) {
    442440                                        $sql['where']['member_type'] = "u.{$this->uid_name} IN ( SELECT object_id FROM $wpdb->term_relationships WHERE {$matches[0]} )";
     441                                } elseif ( false !== strpos( $member_type_sql_clauses['where'], '0 = 1' ) ) {
     442                                        $sql['where']['member_type'] = $this->no_results['where'];
    443443                                }
    444444                        }
Note: See TracChangeset for help on using the changeset viewer.