[buddypress-trac] [BuddyPress] #5099: Total groups wrong when fetching groups with meta query

buddypress-trac noreply at wordpress.org
Tue Jul 16 06:49:10 UTC 2013

#5099: Total groups wrong when fetching groups with meta query
 Reporter:  r-a-y         |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  1.8
Component:  Groups        |     Version:  1.8-beta
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |
Changes (by r-a-y):

 * keywords:  needs-patch => has-patch


 01.patch changes the way the groups total SQL statement is generated.

 Before, we used two different SQL statements in `BP_Groups_Group::get()`.
 One for the paged groups and the other for total groups.  This isn't so
 great as changes in one SQL statement will need to be mirrored in the
 other, which can lead to inaccuracies.  The new meta query parameter
 outlines this problem.

 Instead of fiddling around with the total groups SQL to work with the meta
 query parameter, the attached patch uses the paged SQL statement to
 generate the total groups SQL statement.  See line 451 of the patch.

 Because of this, the `$total_sql` array is now not used.  However, for
 plugin devs using `$total_sql` in the `'bp_groups_get_total_groups_sql'`
 filter, we still need to keep it for the time being.  So, I've introduced
 a new method - `get_deprecated_total_groups_sql()` - to move the old code
 away from the `get()` method with the hopes of removing it later.

 Patch passes the unit test attached to this ticket.  However, this could
 use more testing.

 I know this is quite a big change, but I think this is cleaner and makes
 more sense.  Feel free to implement an alternative fix if this is deemed
 too radical a change as 1.8 is due to hit some time very soon.

Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5099#comment:1>
BuddyPress <http://buddypress.org/>

More information about the buddypress-trac mailing list