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-templates/bp-legacy/buddypress-functions.php

    r8201 r8251  
    707707        exit( '-1<div id="message" class="error"><p>' . __( 'There was a problem posting your update, please try again.', 'buddypress' ) . '</p></div>' );
    708708
    709     $last_id = isset( $_POST['offset'] ) ? absint( $_POST['offset'] ) + 1 : 0;
    710     if ( $last_id ) {
    711         $activity_args = array( 'offset' => $last_id );
    712         $bp->activity->new_update_id = $activity_id;
     709    $last_recorded = isset( $_POST['since'] ) ? date( 'Y-m-d H:i:s', intval( $_POST['since'] ) ) : 0;
     710    if ( $last_recorded ) {
     711        $activity_args = array( 'since' => $last_recorded );
     712        $bp->activity->last_recorded = $last_recorded;
    713713        add_filter( 'bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1 );
    714714    } else {
     
    723723    }
    724724
    725     if ( ! empty( $last_id ) ) {
     725    if ( ! empty( $last_recorded ) ) {
    726726        remove_filter( 'bp_get_activity_css_class', 'bp_activity_newest_class', 10, 1 );
    727727    }
Note: See TracChangeset for help on using the changeset viewer.