Skip to:
Content

BuddyPress.org

Opened 12 years ago

Closed 12 years ago

#4306 closed defect (bug) (fixed)

Filter name 'groups_total_public_forum_topic_count' used in two places

Reported by: djpaul's profile DJPaul Owned by:
Milestone: 1.7 Priority: normal
Severity: normal Version:
Component: Groups Keywords:
Cc:

Description

The filter 'groups_total_public_forum_topic_count' is used in both groups_total_public_forum_topic_count() and in get_global_forum_topic_count().

The first filters an integer, the second a block of SQL.

Change History (6)

#1 @boonebgorges
12 years ago

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 :)

#2 @DJPaul
12 years ago

I think we should intentionally remove the incorrectly-named filter from get_global_forum_topic_count(). I mean, if anyone's ever used this filter for one purpose, it *must* have broken their templates for the other. I'm not sure maintaining backpat when it's so clearly broken is worth it in the long run.

#3 @boonebgorges
12 years ago

  • Keywords 1.7-early added
  • Milestone changed from Awaiting Review to Future Release

That's fine with me. I vote that we immediately put in an inline comment that says "don't use this, it will be removed", and then we rip it from trunk as soon as 1.6 is released.

#4 @djpaul
12 years ago

(In [6153]) Prevent invalid SQL query when getting global forum topic count. Fixes #4314, also see #4306. Props boonebgorges for initial patch.

  • The 'groups_total_public_forum_topic_count' filter in groups_total_public_forum_topic_count() has been deprecated, and will be removed in BP 1.7.
  • Use the new 'get_global_forum_topic_count_extra_sql' filter instead.

#5 @boonebgorges
12 years ago

  • Keywords 1.7-early removed
  • Milestone changed from Future Release to 1.7

#6 @DJPaul
12 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in r6241

Note: See TracTickets for help on using tickets.