Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/08/2014 06:55:30 AM (11 years ago)
Author:
imath
Message:

Insert a new "since" filter for the activity stream to be used by HeartBeat check feature

In rare cases, the field date_recorded of the activity table can be updated to a date greater than the most recent activity in terms of id.
The Heartbeat feature was based on the id field so far, while the activity stream is sorting items according to the date_recorded field. As a result, in this very particular case, activities with an id greater than the activity (which date has been updated) will be loaded again in the stream and this until a new activity is published.
To prevent this to happen, we introduce this new "since" filter to be used by the HeartBeat feature once it gets the timestamp of the most recent activity displayed in the stream.

props SGr33n, boonebgorges, imath

Fixes #5505

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-template.php

    r8201 r8251  
    548548        'secondary_id'      => false,        // secondary object ID to filter on e.g. a post_id
    549549        'offset'            => false,        // return only items >= this ID
     550        'since'             => false,        // return only items recorded since this Y-m-d H:i:s date
    550551
    551552        'meta_query'        => false,        // filter on activity meta. See WP_Meta_Query for format
     
    642643    if ( isset( $_GET['afilter'] ) && apply_filters( 'bp_activity_enable_afilter_support', false ) )
    643644        $filter = array( 'object' => $_GET['afilter'] );
    644     else if ( ! empty( $user_id ) || ! empty( $object ) || ! empty( $action ) || ! empty( $primary_id ) || ! empty( $secondary_id ) || ! empty( $offset ) )
    645         $filter = array( 'user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id, 'offset' => $offset );
     645    else if ( ! empty( $user_id ) || ! empty( $object ) || ! empty( $action ) || ! empty( $primary_id ) || ! empty( $secondary_id ) || ! empty( $offset ) || ! empty( $since ) )
     646        $filter = array( 'user_id' => $user_id, 'object' => $object, 'action' => $action, 'primary_id' => $primary_id, 'secondary_id' => $secondary_id, 'offset' => $offset, 'since' => $since );
    646647    else
    647648        $filter = false;
     
    28062807function bp_activity_recurse_comments_activity_ids( $activity = array(), $activity_ids = array() ) {
    28072808    if ( is_array( $activity ) && ! empty( $activity['activities'] ) ) {
    2808         $activity = $activity['activities'][0]; 
     2809        $activity = $activity['activities'][0];
    28092810    }
    28102811
Note: See TracChangeset for help on using the changeset viewer.