[buddypress-trac] [BuddyPress] #4306: Filter name 'groups_total_public_forum_topic_count' used in two places

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Wed Jun 27 12:40:59 UTC 2012


#4306: Filter name 'groups_total_public_forum_topic_count' used in two places
--------------------------+------------------------------
 Reporter:  DJPaul        |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Groups        |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+------------------------------

Comment (by boonebgorges):

 Groan. It looks like it's been like this pretty much forever.

 https://encrypted.google.com/#hl=en&output=search&sclient=psy-
 ab&q=site:plugins.svn.wordpress.org+groups_total_public_forum_topic_count&oq=site:plugins.svn.wordpress.org+groups_total_public_forum_topic_count&gs_l=hp.3...2283.11948.0.12398.60.44.13.0.0.0.252.3954.34j8j2.44.0...0.0.MpE439_4T_Q&pbx=1&bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&fp=6e2d19fc4276c40c&biw=1244&bih=864

 It doesn't really look like anyone's using either, at least in a public
 plugin. I suggest that we keep the filter name in the function
 groups_total_public_forum_topic_count() (for consistency in naming, and
 because I'd think that this is the more likely place for people to have
 filtered), and then do something like the following in
 `BP_Groups_Group::get_global_forum_topic_count()`:

 {{{
 // Provide backward-compatibility for the
 groups_total_public_forum_topic_count
                 // SQL filter.
                 // Developers: DO NOT use this filter. Use
 get_global_forum_topic_count_extra_sql
                 // See https://buddypress.trac.wordpress.org/ticket/4306
                 $maybe_extra_sql = apply_filters(
 'groups_total_public_forum_topic_count', $bp->groups->filter_sql, $type );

                 if ( is_int( $maybe_extra_sql ) ) {
                         $extra_sql = $bp->groups->filter_sql;
                 } else {
                         $extra_sql = $maybe_extra_sql;
                 }

                 // Developers: use this filter instead
                 $extra_sql = apply_filters(
 'get_global_forum_topic_count_extra_sql', $bp->groups->filter_sql, $type
 );
 }}}

 That way, if anyone is using the old filter for SQL reasons, it'll still
 work. It may also be worthwhile to do something similar in
 `groups_total_public_forum_topic_count()` (make sure that the filter
 returns an int value).

 Alternatively, we could just remove the filter and see what comes. It's
 dumb anyway :)

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


More information about the buddypress-trac mailing list