Make WordPress Core

Opened 16 years ago

Closed 15 years ago

#16676 closed defect (bug) (fixed)

ms-load.php::get_current_site_name floads needlessly the cache

Reported by: mark-k Owned by: ryan
Priority: normal Milestone: 3.3
Component: Multisite Version: 3.1
Severity: normal Keywords: has-patch commit
Cc: Focuses:

Description

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;
}

Attachments (1)

16676.diff​ (709 bytes ) - added by solarissmoke 16 years ago.

Download all attachments as: .zip

Change History (5)

@solarissmoke
16 years ago

#1 @solarissmoke
16 years ago

  • Keywords has-patch added

#2 @scribu
16 years ago

  • Component General → Multisite
  • Keywords commit added
  • Milestone Awaiting Review → Future Release

#3 @SergeyBiryukov
15 years ago

  • Milestone Future Release → 3.3

#4 @ryan
15 years ago

  • Owner set to ryan
  • Resolution → fixed
  • Status new → closed

In [18604]:

Don't set the site_name cache on every call to get_current_site_name(). Props mark-k, solarissmoke. fixes #16676

Note: See TracTickets for help on using tickets.