Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/15/2014 08:38:11 PM (12 years ago)
Author:
r-a-y
Message:

Check cache for count functions that return zero.

Some of our count functions were previously setting counts of zero
correctly, but the functions themselves were not referencing the cache
properly when the count returned zero. This led to unnecessary database
queries and we hate extra queries!

This commit addresses the problem and adds unit tests.

Props r-a-y, boonebgorges.

Fixes #6012.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-functions.php

    r9210 r9231  
    598598        global $wpdb;
    599599
    600         if ( !$count = wp_cache_get( 'bp_total_member_count', 'bp' ) ) {
     600        $count = wp_cache_get( 'bp_total_member_count', 'bp' );
     601
     602        if ( false === $count ) {
    601603                $status_sql = bp_core_get_status_sql();
    602604                $count = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->users} WHERE {$status_sql}" );
Note: See TracChangeset for help on using the changeset viewer.