Skip to:
Content

BuddyPress.org

Changeset 9082


Ignore:
Timestamp:
10/14/2014 01:40:07 PM (6 years ago)
Author:
boonebgorges
Message:

Fix group meta query SQL manipulation.

The wildcard operators were acting too greedily, preventing some JOIN clauses
from being recognized and resulting in invalid SQL syntax. This problem had
previously been masked by ideosyncracies of WP's WP_Meta_Query SQL syntax,
which changed in [WP29887].

This change should be considered a band-aid fix for what is already a band-aid
fix. The proper resolution for this issue is to migrate away from the comma
syntax for JOINs used in BP_Groups_Group. See #5874, #5451.

File:
1 edited

Legend:

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

    r9027 r9082  
    896896            // the more general query syntax to accord better with
    897897            // BP/WP convention
    898             preg_match_all( '/INNER JOIN (.*) ON/', $meta_sql['join'], $matches_a );
    899             preg_match_all( '/ON \((.*)\)/', $meta_sql['join'], $matches_b );
     898            preg_match_all( '/JOIN (.+?) ON/', $meta_sql['join'], $matches_a );
     899            preg_match_all( '/ON \((.+?)\)/', $meta_sql['join'], $matches_b );
    900900
    901901            if ( ! empty( $matches_a[1] ) && ! empty( $matches_b[1] ) ) {
    902902                $sql_array['join']  = implode( ',', $matches_a[1] ) . ', ';
    903                 $sql_array['where'] = $meta_sql['where'] . ' AND ' . implode ( ' AND ', $matches_b[1] );
     903                $sql_array['where'] = $meta_sql['where'] . ' AND ' . implode( ' AND ', $matches_b[1] );
    904904            }
    905905        }
Note: See TracChangeset for help on using the changeset viewer.