Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/14/2024 06:26:17 AM (21 months ago)
Author:
imath
Message:

Activity: make sure streams are paginated the right way

In [13344] we made sure to avoid the last entry(ies) of the stream to be duplicated if some other members published other entry(ies) just before a user clicked on the "Load More" link.

2 mistakes were made while generating the BP_Activity_Activity MySQL query clause as well as the Load More link query variable causing a regression as some activity entries were wrongly skipped from display each time a user was clicking on this link.

  1. The MySQL query clause built in BP_Activity_Activity::get_filter_sql() needs to also include the last inserted Activity ID using the <= operator instead of the < one.
  2. The query variable added to the Load More link needs to remain the last inserted Activity ID at the time the stream is first displayed.

Props testovac
Antiprops imath

See #9094
Closes https://github.com/buddypress/buddypress/pull/229

File:
1 edited

Legend:

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

    r13520 r13724  
    426426        );
    427427
    428         // Try to include the offset arg.
    429         $last_displayed_activity = reset( $activities_template->activities );
    430         if ( isset( $last_displayed_activity->id ) && $last_displayed_activity->id ) {
    431             $load_more_args['offset_lower'] = (int) $last_displayed_activity->id;
     428        // Use the first posted offset arg to transport it for each following page links.
     429        if ( isset( $_POST['offset_lower'] ) && $_POST['offset_lower'] ) {
     430            $load_more_args['offset_lower'] = (int) wp_unslash( $_POST['offset_lower'] );
     431
     432            // Try to include the offset arg to the second page link.
     433        } elseif ( 1 === $activities_template->pag_page ) {
     434            $last_displayed_activity = reset( $activities_template->activities );
     435            if ( isset( $last_displayed_activity->id ) && $last_displayed_activity->id ) {
     436                $load_more_args['offset_lower'] = (int) $last_displayed_activity->id;
     437            }
    432438        }
    433439
Note: See TracChangeset for help on using the changeset viewer.