Skip to:
Content

BuddyPress.org

Changeset 6881


Ignore:
Timestamp:
04/02/2013 05:34:41 PM (11 years ago)
Author:
boonebgorges
Message:

Cache the value of show_avatars, and check cached value in bp_core_fetch_avatar()

Calling bp_get_option() requires calling switch_to_blog() when not on the root
blog, so we want to avoid doing gratuitous calls to that function. This
changeset moves the bp_get_option( 'show_avatars' ) call to the BP avatar
initialization process, so that it's only checked once per page load.
Subsequent checks of the show_avatar setting are then made against the cached
value.

Fixes #4908

Props wpdennis

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-avatars.php

    r6812 r6881  
    7272    $bp->avatar->url         = bp_core_avatar_url();
    7373
     74    // Cache the root blog's show_avatars setting, to avoid unnecessary
     75    // calls to switch_to_blog()
     76    $bp->avatar->show_avatars = (bool) bp_get_option( 'show_avatars' );
     77
    7478    // Backpat for pre-1.5
    7579    if ( ! defined( 'BP_AVATAR_UPLOAD_PATH' ) )
     
    97101
    98102    // If avatars are disabled for the root site, obey that request and bail
    99     if ( ! bp_get_option( 'show_avatars' ) )
     103    if ( ! buddypress()->avatar->show_avatars )
    100104        return;
    101105
Note: See TracChangeset for help on using the changeset viewer.