Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/09/2014 06:33:05 PM (8 years ago)
Author:
boonebgorges
Message:

Disable COUNT queries by default in bp_activity_get() stack

The COUNT query performed to get the total activity count has proven to be a
performance bottleneck on large sites. Moreover, the way that activity items
are displayed on the front end (using the Load More link) means that the total
count is not actually used by BuddyPress in most cases. To reduce query
overhead, we introduce a 'count_total' parameter to the bp_activity_get()
stack, and set it to false by default.

For backward compatibility, a few additional changes are introduced:

  • In the activity-loop.php template, the <noscript> pagination markup is removed. In its place, the Load More link is refactored so that it loads the next available page of activity items.
  • The mechanism used to determine whether there are more activity items to show (bp_activity_has_more_items()) has been refined; when no COUNT query takes place, we query for the $per_page value + 1 to infer whether more items are available.

Fixes #5629

Props boonebgorges, r-a-y

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-legacy/buddypress/activity/activity-loop.php

    r8155 r8491  
    22
    33<?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ) ) ) : ?>
    4 
    5     <?php /* Show pagination if JS is not enabled, since the "Load More" link will do nothing */ ?>
    6     <noscript>
    7         <div class="pagination">
    8             <div class="pag-count"><?php bp_activity_pagination_count(); ?></div>
    9             <div class="pagination-links"><?php bp_activity_pagination_links(); ?></div>
    10         </div>
    11     </noscript>
    124
    135    <?php if ( empty( $_POST['page'] ) ) : ?>
     
    2618
    2719        <li class="load-more">
    28             <a href="#more"><?php _e( 'Load More', 'buddypress' ); ?></a>
     20            <a href="<?php bp_activity_load_more_link() ?>"><?php _e( 'Load More', 'buddypress' ); ?></a>
    2921        </li>
    3022
Note: See TracChangeset for help on using the changeset viewer.