WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 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
Milestone: 3.3 Priority: normal
Severity: normal Version: 3.1
Component: Multisite Keywords: has-patch commit
Focuses: Cc:

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 3 years ago.

Download all attachments as: .zip

Change History (5)

solarissmoke3 years ago

comment:1 solarissmoke3 years ago

  • Keywords has-patch added

comment:2 scribu3 years ago

  • Component changed from General to Multisite
  • Keywords commit added
  • Milestone changed from Awaiting Review to Future Release

comment:3 SergeyBiryukov3 years ago

  • Milestone changed from Future Release to 3.3

comment:4 ryan3 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to 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.