Skip to:
Content

BuddyPress.org

Opened 10 years ago

Closed 10 years ago

Last modified 10 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
Priority: normal Milestone: 2.8
Component: Activity Version:
Severity: normal 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 10 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
10 years ago

  • Milestone Awaiting Review2.6

Passing both parameters sounds good to me, imath!

#2 @imath
10 years ago

  • Keywords needs-patch added

#3 @DJPaul
10 years ago

  • Milestone 2.6Future Release

#4 @Offereins
10 years ago

  • Cc lmoffereins@… added
  • Milestone Future Release2.8

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

@sanket.parmar
10 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
10 years ago

  • Keywords has-patch added; needs-patch removed

#6 @boonebgorges
10 years ago

  • Owner set to boonebgorges
  • Status newassigned

@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
10 years ago

  • Resolutionfixed
  • Status assignedclosed

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
10 years ago

Hi @boonebgorges

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

#9 @boonebgorges
10 years ago

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

#10 @sanket.parmar
10 years ago

Hi @boonebgorges

Thank you :)

Note: See TracTickets for help on using tickets.