[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 20:31:41 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):

 Good call, r-a-y! Not sure what your idea is, but how about this:

 - on `bp_activity_before_save`: look for mentions; do the preg_replace()
 on $activity->content to turn into links; and then, for each found
 username:

 {{{
 $bp->activity->pending_mention_notifications[] = $username;
 }}}

 - Then, on `bp_activity_after_save`,

 {{{
 foreach ( $bp->activity->pending_mention_notifications as $username ) {
     // do the notification for $username
 }
 unset( $bp->activity->pending_mention_notifications );
 }}}

 This seems sorta ugly on the surface, but on further reflection, it kinda
 makes sense: we have to parse and modify the content *before* save, and we
 should only be sending notifications *after* an item has been successfully
 created. The (very) temporary entry in the $bp global acts like a very
 short-term cache of the notifications that have to be sent, which is
 perhaps not the peak of elegance, but it's not too bad and it would work
 :)

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


More information about the buddypress-trac mailing list