Skip to:
Content

BuddyPress.org

Changeset 8476


Ignore:
Timestamp:
06/04/2014 06:24:12 PM (10 years ago)
Author:
boonebgorges
Message:

Clean up parsed meta_query clauses before performing preg_replaces() in BP_Groups_Group::get_meta_query_sql()

Some weaknesses in parsing were exposed by upstream changes. See
https://core.trac.wordpress.org/ticket/25538#comment:23.

This changeset makes the parsing less brittle by relying less on the details of
the line breaks introduced by WP into the query string.

See #5682

File:
1 edited

Legend:

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

    r8397 r8476  
    897897
    898898                $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
    899903                foreach( $matches_b[1] as $key => $group_id_clause ) {
    900904                    $sql_array['where'] .= ' ' . preg_replace( '/^(AND\s+[\(\s]+)/', '$1' . $group_id_clause . ' AND ', ltrim( $meta_query_where_clauses[ $key ] ) );
Note: See TracChangeset for help on using the changeset viewer.