Skip to:
Content

BuddyPress.org

Changeset 7792


Ignore:
Timestamp:
02/05/2014 07:17:01 PM (10 years ago)
Author:
boonebgorges
Message:

Consult cache first when checking BP_XProfile_ProfileData::exists()

See #1332

Location:
trunk
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-xprofile/bp-xprofile-classes.php

    r7791 r7792  
    11311131        global $wpdb, $bp;
    11321132
    1133         $retval = $wpdb->get_row( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_data} WHERE user_id = %d AND field_id = %d", $this->user_id, $this->field_id ) );
     1133        // Check cache first
     1134        $cached = wp_cache_get( $this->field_id, 'bp_xprofile_data_' . $this->user_id );
     1135
     1136        if ( $cached ) {
     1137            $retval = true;
     1138        } else {
     1139            $retval = $wpdb->get_row( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_data} WHERE user_id = %d AND field_id = %d", $this->user_id, $this->field_id ) );
     1140        }
    11341141
    11351142        return apply_filters_ref_array( 'xprofile_data_exists', array( (bool)$retval, $this ) );
Note: See TracChangeset for help on using the changeset viewer.