Skip to:
Content

BuddyPress.org

Opened 8 years ago

Closed 8 years ago

#6850 closed enhancement (fixed)

Filter for activity sql JOIN query

Reported by: jozik's profile jozik Owned by: boonebgorges's profile boonebgorges
Milestone: 2.5 Priority: normal
Severity: normal Version:
Component: Activity Keywords:
Cc:

Description

Similar to #2674, can you please add filter for activity sql JOIN query?

bp-activity/classes/class-bp-activity-activity.php line 460
BP_Activity_Activity::get()

Existing WHERE condition filter

$where_conditions = apply_filters( 'bp_activity_get_where_conditions', $where_conditions, $r, $select_sql, $from_sql, $join_sql );
$where_sql = 'WHERE ' . join( ' AND ', $where_conditions );

Sometimes cannot be used without JOIN filter.

Is there possibility to add something like?:

apply_filters( 'bp_activity_get_join', array( $join_sql ), $r, $select_sql, $from_sql );

Thank you.

===

I'm trying to exclude some activities based on data in other tables
without affecting pagination, counting and other stuff.

Change History (3)

#1 @DJPaul
8 years ago

  • Milestone changed from Awaiting Review to Under Consideration

@boone I think it was Activity you did a lot of work on a year ago or so -- does this suggestion make sense?

#2 @boonebgorges
8 years ago

  • Milestone changed from Under Consideration to 2.5
  • Owner set to boonebgorges
  • Status changed from new to assigned

I hate introducing filters on SQL queries, but @jozik is correct that the existing WHERE filter is not completely usable without a corresponding filter on JOIN. (You could filter the concatenated query to make this work, but you'd need some fancy regex.) Let's just do it.

#3 @boonebgorges
8 years ago

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

In 10560:

Introduced 'bp_activity_get_join_sql' filter.

This filter on the JOIN clause of the SQL query in BP_Activity_Activity::get()
makes it more practical to modify the activity query, especially when used in
conjuction with the corresponding filter on the WHERE clause.

Props jozik.
Fixes #6850.

Note: See TracTickets for help on using tickets.