WordPress.org

Make WordPress Core

Changeset 13116


Ignore:
Timestamp:
02/13/2010 06:56:50 PM (11 years ago)
Author:
wpmuguru
Message:

use object cache on get_blog_option on current blog, props sivel, See #11644

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/ms-functions.php

    r13106 r13116  
    251251    $value = wp_cache_get( $key, "site-options" );
    252252    if ( $value == null ) {
    253         $blog_prefix = $wpdb->get_blog_prefix( $blog_id );
    254         $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$blog_prefix}options WHERE option_name = %s", $setting ) );
    255         if ( is_object( $row ) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values
    256             $value = $row->option_value;
    257             if ( $value == false )
     253        if ( $blog_id == $wpdb->blogid ) {
     254            $value = get_option( $setting, $default );
     255            $notoptions = wp_cache_get( 'notoptions', 'options' );
     256            if ( isset( $notoptions[$setting] ) )
     257                wp_cache_set( $key, 'noop', 'site-options' );
     258            elseif ( $value == false )
    258259                wp_cache_set( $key, 'falsevalue', 'site-options' );
    259260            else
    260261                wp_cache_set( $key, $value, 'site-options' );
    261         } else { // option does not exist, so we must cache its non-existence
    262             wp_cache_set( $key, 'noop', 'site-options' );
    263             $value = $default;
     262        } else {
     263            $blog_prefix = $wpdb->get_blog_prefix( $blog_id );
     264            $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$blog_prefix}options WHERE option_name = %s", $setting ) );
     265            if ( is_object( $row ) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values
     266                $value = $row->option_value;
     267                if ( $value == false )
     268                    wp_cache_set( $key, 'falsevalue', 'site-options' );
     269                else
     270                    wp_cache_set( $key, $value, 'site-options' );
     271            } else { // option does not exist, so we must cache its non-existence
     272                wp_cache_set( $key, 'noop', 'site-options' );
     273                $value = $default;
     274            }
    264275        }
    265276    } elseif ( $value == 'noop' ) {
Note: See TracChangeset for help on using the changeset viewer.