Skip to:
Content

BuddyPress.org

Opened 3 years ago

Closed 3 years ago

#7374 closed enhancement (fixed)

Add new filter to bp_activity_do_heartbeat()

Reported by: wordpressrene Owned by: boonebgorges
Milestone: 2.8 Priority: normal
Severity: normal Version:
Component: Activity Keywords: good-first-bug has-patch commit
Cc:

Description

If you use the activity loop on another page than the activity page of BuddyPress, the automatic loading of new posts via heartbeat API is disabled, because the function "bp_activity_do_heartbeat()" returns false. This seems logic, because it is neither the activity directory nor the group activity.
If there is a filter in "bp_activity_do_heartbeat()" it would be possible to use the heartbeat functions in this case. Simply change return $retval; to return apply_filters( 'bp_activity_do_heartbeat', $retval ); in bp-activity/bp-activity-functions.php:3764

Attachments (2)

7374.patch (380 bytes) - added by wordpressrene 3 years ago.
7374-2.patch (866 bytes) - added by wordpressrene 3 years ago.
add second patch according to @boonebgorges comment

Download all attachments as: .zip

Change History (11)

#1 @DJPaul
3 years ago

  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to Future Release

Sure thing, @wordpressrene. Do you fancy patching it up?

@wordpressrene
3 years ago

#2 @slaFFik
3 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Future Release to 2.8
  • Summary changed from Filter "bp_activity_do_heartbeat()" to Add new filter to bp_activity_do_heartbeat()
  • Type changed from defect (bug) to enhancement
  • Version 2.7.2 deleted

#3 @DJPaul
3 years ago

Great, thanks for the patch @wordpressrene. We'll look at it soon!

Just a tip -- if you attach a patch to a Trac ticket, it's best to write a comment at the same time. Most people don't receive email updates about a Trac ticket unless a comment is left.

#4 @boonebgorges
3 years ago

  • Keywords needs-docs added; has-patch removed

@wordpressrene Thank you very much for the patch! A few comments:

Would you like to revise your patch, @wordpressrene ?

#5 follow-up: @wordpressrene
3 years ago

I will correct the code.

I don't know if somebody, who hasn't activated the heartbeat refresh needs to have the filter when returning early. In addition to this you can filter the return value of bp_is_activity_heartbeat_active() to prevent returning early. So I think we don't need to add the filter here. What do you think @boonebgorges?

Last edited 3 years ago by wordpressrene (previous) (diff)

@wordpressrene
3 years ago

add second patch according to @boonebgorges comment

#6 @wordpressrene
3 years ago

  • Keywords has-patch added; needs-docs removed

#7 @DJPaul
3 years ago

  • Keywords commit added

Patch looks good (whoever commits it, merge the two ifs into a one liner, they don't need to be nested).

#8 in reply to: ↑ 5 @boonebgorges
3 years ago

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

Replying to wordpressrene:

I will correct the code.

I don't know if somebody, who hasn't activated the heartbeat refresh needs to have the filter when returning early. In addition to this you can filter the return value of bp_is_activity_heartbeat_active() to prevent returning early. So I think we don't need to add the filter here. What do you think @boonebgorges?

I agree it's unlikely that the filter would be useful in this case, but for consistency's sake, I think it makes sense for the return value always to be filtered. Thanks for the patch!

#9 @boonebgorges
3 years ago

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

In 11300:

Activity: Filter the return value of bp_activity_do_heartbeat().

Props wordpressrene.
Fixes #7374.

Note: See TracTickets for help on using tickets.