Skip to:
Content

BuddyPress.org

Changeset 12152


Ignore:
Timestamp:
05/31/2018 05:21:25 PM (4 years ago)
Author:
r-a-y
Message:

Activity: After r11101, fix notices when using the legacy activity query.

r11101 introduced incremented cache improvements when fetching activity
items. However, if the legacy activity query is force-enabled and if the
'count_total' parameter is passed, a few notices are thrown due to
the $cache_group variable not being defined.

This commit addresses this by declaring the $cache_group variable during
the legacy activity query block.

See #7245.

Fixes #7848 (3.x branch).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/src/bp-activity/classes/class-bp-activity-activity.php

    r11867 r12152  
    614614
    615615            if ( ! empty( $page ) && ! empty( $per_page ) ) {
    616                 $pag_sql    = $wpdb->prepare( "LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page );
     616                $pag_sql = $wpdb->prepare( "LIMIT %d, %d", absint( ( $page - 1 ) * $per_page ), $per_page );
    617617
    618618                /** This filter is documented in bp-activity/bp-activity-classes.php */
    619                 $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}, a.id {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
     619                $activity_sql = apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}, a.id {$sort} {$pag_sql}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql );
    620620            } else {
    621                 $pag_sql    = '';
     621                $pag_sql = '';
    622622
    623623                /**
     
    632632                 * @param string $sort       Final sort direction for legacy query.
    633633                 */
    634                 $activities = $wpdb->get_results( apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}, a.id {$sort}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql ) );
    635             }
     634                $activity_sql = apply_filters( 'bp_activity_get_user_join_filter', "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}, a.id {$sort}", $select_sql, $from_sql, $where_sql, $sort, $pag_sql );
     635            }
     636
     637            /*
     638             * Queries that include 'last_activity' are cached separately,
     639             * since they are generally much less long-lived.
     640             */
     641            if ( preg_match( '/a\.type NOT IN \([^\)]*\'last_activity\'[^\)]*\)/', $activity_sql ) ) {
     642                $cache_group = 'bp_activity';
     643            } else {
     644                $cache_group = 'bp_activity_with_last_activity';
     645            }
     646
     647            $activities = $wpdb->get_results( $activity_sql );
    636648
    637649            // Integer casting for legacy activity query.
Note: See TracChangeset for help on using the changeset viewer.