Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/20/2014 06:32:30 PM (12 years ago)
Author:
boonebgorges
Message:

Simplify logic that transforms WP_Meta_Query SQL for Groups queries

This simplified logic fixes a bug related to the use of the 'compare'
operator in certain cases.

Fixes #5824

Props imath

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-classes.php

    r8934 r8949  
    892892
    893893                        if ( ! empty( $matches_a[1] ) && ! empty( $matches_b[1] ) ) {
    894                                 $sql_array['join']  = implode( ',', $matches_a[1] ). ', ';
    895 
    896                                 $sql_array['where'] = '';
    897 
    898                                 $meta_query_where_clauses = explode( "\n", $meta_sql['where'] );
    899 
    900                                 // Trim empties
    901                                 $meta_query_where_clauses = array_values( array_filter( $meta_query_where_clauses ) );
    902 
    903                                 foreach( $matches_b[1] as $key => $group_id_clause ) {
    904                                         $sql_array['where'] .= ' ' . preg_replace( '/^(AND\s+[\(\s]+)/', '$1' . $group_id_clause . ' AND ', ltrim( $meta_query_where_clauses[ $key ] ) );
    905                                 }
    906 
     894                                $sql_array['join']  = implode( ',', $matches_a[1] ) . ', ';
     895                                $sql_array['where'] = $meta_sql['where'] . ' AND ' . implode ( ' AND ', $matches_b[1] );
    907896                        }
    908897                }
Note: See TracChangeset for help on using the changeset viewer.