Use get_site_option in add/update_site_option for caching and filtering benefits. fixes #18478

git-svn-id: http://svn.automattic.com/wordpress/trunk@18588 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
duck_ 2011-08-23 20:45:48 +00:00
parent 56f6f97125
commit 7213d24276
1 changed files with 6 additions and 6 deletions

View File

@ -3799,14 +3799,14 @@ function add_site_option( $option, $value ) {
} else { } else {
$cache_key = "{$wpdb->siteid}:$option"; $cache_key = "{$wpdb->siteid}:$option";
if ( $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) ) ) if ( false !== get_site_option( $option ) )
return false; return false;
$value = sanitize_option( $option, $value ); $value = sanitize_option( $option, $value );
wp_cache_set( $cache_key, $value, 'site-options' ); wp_cache_set( $cache_key, $value, 'site-options' );
$_value = $value; $_value = $value;
$value = maybe_serialize($value); $value = maybe_serialize( $value );
$result = $wpdb->insert( $wpdb->sitemeta, array('site_id' => $wpdb->siteid, 'meta_key' => $option, 'meta_value' => $value ) ); $result = $wpdb->insert( $wpdb->sitemeta, array('site_id' => $wpdb->siteid, 'meta_key' => $option, 'meta_value' => $value ) );
$value = $_value; $value = $_value;
} }
@ -3886,14 +3886,14 @@ function update_site_option( $option, $value ) {
if ( $value === $oldvalue ) if ( $value === $oldvalue )
return false; return false;
if ( $value && false === $oldvalue )
return add_site_option( $option, $value );
if ( !is_multisite() ) { if ( !is_multisite() ) {
$result = update_option( $option, $value ); $result = update_option( $option, $value );
} else { } else {
$cache_key = "{$wpdb->siteid}:$option";
if ( $value && !$wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) ) )
return add_site_option( $option, $value );
$value = sanitize_option( $option, $value ); $value = sanitize_option( $option, $value );
$cache_key = "{$wpdb->siteid}:$option";
wp_cache_set( $cache_key, $value, 'site-options' ); wp_cache_set( $cache_key, $value, 'site-options' );
$_value = $value; $_value = $value;