[buddypress-trac] [BuddyPress] #3980: bp_activity_at_name_filter_updates() causes activity to be saved twice

buddypress-trac noreply at wordpress.org
Fri Nov 23 16:10:08 UTC 2012

#3980: bp_activity_at_name_filter_updates() causes activity to be saved twice
 Reporter:  r-a-y         |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  Activity      |     Version:  1.5
 Severity:  normal        |  Resolution:
 Keywords:  dev-feedback  |

Comment (by boonebgorges):

 What about DJPaul's original suggestion of moving
 `bp_activity_at_name_filter_updates()` to `bp_activity_before_save`? We
 wouldn't have access to `$activity->id` at this point, but do we need it?
 In `bp_activity_at_name_filter()`, the $activity_id seems to be used for
 two things: to check whether the activity is spam, and to increment
 mention counts. Checking for spam is easy enough; the
 `BP_Activity_Activity` object is passed to `bp_activity_before_save`, and
 so we should have access to the `is_spam` property.

 Mention count is a little trickier, because the way we currently do
 mention count incrementing (in `bp_activity_adjust_mention_count()` is to
 call up the activity by id and look for mentions. But this workflow could
 pretty easily be changed so that all we need is the content of the
 activity item. In fact, the current setup requires doing the
 `bp_activity_find_mentions()` logic twice: once in
 `bp_activity_at_name_filter()` and again in the `adjust_mention_count()`
 function. We could abstract the increment-for-member functionality into
 its own standalone function, and then call that inside the `foreach
 $usernames` loop in `bp_activity_at_name_filter()`. Not only would this
 make it so that the activity id is not required, but it would be more

 So it looks like it should be possible to move all this logic to
 `before_save`. Am I missing anything?

Ticket URL: <https://buddypress.trac.wordpress.org/ticket/3980#comment:8>
BuddyPress <http://buddypress.org/>

More information about the buddypress-trac mailing list