[wp-trac] [WordPress Trac] #16676: ms-load.php::get_current_site_name floads needlessly the cache

WordPress Trac wp-trac at lists.automattic.com
Sat Feb 26 06:49:59 UTC 2011


#16676: ms-load.php::get_current_site_name floads needlessly the cache
--------------------------+-----------------------------
 Reporter:  mark-k        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  3.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 wp_cache_set is being called for every call to get_current_site_name even
 when there is no need to update the cache - this cause slam defence
 warning with APC vesion 3.1.6 and generally bad for performance

 the code there should probably be

 {{{
 function get_current_site_name( $current_site ) {
         global $wpdb;

                 $current_site->site_name = wp_cache_get( $current_site->id
 . ':site_name', 'site-options' );
                 if ( ! $current_site->site_name ) {
                         $current_site->site_name = $wpdb->get_var(
 $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = %d
 AND meta_key = 'site_name'", $current_site->id ) );
                         if ( ! $current_site->site_name )
                                 $current_site->site_name = ucfirst(
 $current_site->domain );
             wp_cache_set( $current_site->id . ':site_name',
 $current_site->site_name, 'site-options' );
                 }

         return $current_site;
 }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16676>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list