Skip to:
Content

BuddyPress.org

Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#6971 closed defect (bug) (fixed)

Params for bp_get_activity_content_body filter should be the same whatever the context

Reported by: imath Owned by: boonebgorges
Milestone: 2.8 Priority: normal
Severity: normal Version:
Component: Activity Keywords: has-patch
Cc: lmoffereins@…

Description

In bp-activity-template.php it's :
apply_filters_ref_array( 'bp_get_activity_content_body', array( $activities_template->activity->content, &$activities_template->activity ) )

2 arguments: the content + the full activity object

In bp-legacy/buddypress-functions.php it's
apply_filters( 'bp_get_activity_content_body', $activity->content )

1 argument the content only

In bp-activity-notifications.php it's
apply_filters( 'bp_get_activity_content_body', $params['content'] ); `

1 argument the content only

And in class-bp-activity-list-table.php it's
apply_filters_ref_array( 'bp_get_activity_content_body', array( $item['content'] ) )

1 argument the content only.

As soon as you only need the content, it's ok. But if you need the full activity object to check for additional properties, it's a nightmare!

The filter should always include 2 params imho.

Attachments (1)

6971.diff (3.3 KB) - added by sanket.parmar 3 years ago.
I have added an activity object as a second parameter at all the places where bp_get_activity_content_body filter is applied.

Download all attachments as: .zip

Change History (11)

#1 @r-a-y
4 years ago

  • Milestone changed from Awaiting Review to 2.6

Passing both parameters sounds good to me, imath!

#2 @imath
4 years ago

  • Keywords needs-patch added

#3 @DJPaul
3 years ago

  • Milestone changed from 2.6 to Future Release

#4 @Offereins
3 years ago

  • Cc lmoffereins@… added
  • Milestone changed from Future Release to 2.8

Definitely something I'd like to see fixed for 2.8! I'll have it on my list.

@sanket.parmar
3 years ago

I have added an activity object as a second parameter at all the places where bp_get_activity_content_body filter is applied.

#5 @sanket.parmar
3 years ago

  • Keywords has-patch added; needs-patch removed

#6 @boonebgorges
3 years ago

  • Owner set to boonebgorges
  • Status changed from new to assigned

@sanket.parmar Thanks for the patch! Because the "primary" instance of the filter passes the activity object by reference, we should do the same thing in every instance. In some cases, this means we'll have to switch to apply_filters_ref_array().

#7 @boonebgorges
3 years ago

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

In 11351:

bp_get_activity_content_body filter should receive same params in all contexts.

This changeset makes all instances of bp_get_activity_content_body
consistent by ensuring that they all receive the activity object
as a second parameter. This requires switching to apply_filters_ref_array(),
so that the second param can always be passed by reference.

Props sanket.parmar.
Fixes #6971.

#8 @sanket.parmar
3 years ago

Hi @boonebgorges

Should I replace with apply_filters_ref_array() for all the occurrences?

#9 @boonebgorges
3 years ago

@sanket.parmar No need, I have taken care of it in [11351]. Thanks for the patch!

#10 @sanket.parmar
3 years ago

Hi @boonebgorges

Thank you :)

Note: See TracTickets for help on using tickets.