summaryrefslogtreecommitdiffstats
path: root/wp-includes
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-04-09 18:05:25 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-04-09 18:05:25 +0000
commitdb729dffb361898ff2b0a756dcc90e221d4f739f (patch)
treee070cfdcd1280133c721d4b5fb9ede409fa7268d /wp-includes
parent77d36df7fb95410dceea64cc864e57edce58ee6f (diff)
downloadwordpress-mu-db729dffb361898ff2b0a756dcc90e221d4f739f.tar.gz
wordpress-mu-db729dffb361898ff2b0a756dcc90e221d4f739f.tar.xz
wordpress-mu-db729dffb361898ff2b0a756dcc90e221d4f739f.zip
Speed up switching and caching significantly (experimental!)
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@959 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes')
-rw-r--r--wp-includes/functions.php4
-rw-r--r--wp-includes/wpmu-functions.php41
2 files changed, 43 insertions, 2 deletions
diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index dbe728f..df7ad74 100644
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -210,8 +210,8 @@ function get_option($setting) {
if ( $switched != false || defined('WP_INSTALLING') != false ) {
wp_cache_delete($setting, 'options');
- wp_cache_delete('notoptions', 'options');
- wp_cache_delete('alloptions', 'options');
+ #wp_cache_delete('notoptions', 'options');
+ #wp_cache_delete('alloptions', 'options');
}
// prevent non-existent options from triggering multiple queries
diff --git a/wp-includes/wpmu-functions.php b/wp-includes/wpmu-functions.php
index bf13d16..f766dfb 100644
--- a/wp-includes/wpmu-functions.php
+++ b/wp-includes/wpmu-functions.php
@@ -284,6 +284,7 @@ function update_site_option( $key, $value ) {
wp_cache_delete( $wpdb->siteid . $key, 'site-options' );
}
+/*
function get_blog_option( $id, $key, $default='na' ) {
switch_to_blog($id);
$opt = get_option( $key );
@@ -291,17 +292,55 @@ function get_blog_option( $id, $key, $default='na' ) {
return $opt;
}
+*/
+
+function get_blog_option( $blog_id, $setting, $default='na' ) {
+ global $wpdb, $wpmuBaseTablePrefix;
+
+ $key = $blog_id."-".$setting."-blog_option";
+ $value = wp_cache_get( $key, "site-options" );
+ if( $value == null ) {
+ $row = $wpdb->get_row( "SELECT * FROM {$wpmuBaseTablePrefix}{$blog_id}_options WHERE option_name = '{$setting}'" );
+ if( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values
+ $value = $row->option_value;
+ if( $value == false )
+ $value = 'falsevalue';
+ wp_cache_set($key, $value, 'site-options');
+ } else { // option does not exist, so we must cache its non-existence
+ wp_cache_set($key, 'noop', 'site-options');
+ }
+ } elseif( $value == 'noop' ) {
+ return false;
+ } elseif( $value == 'falsevalue' ) {
+ return false;
+ }
+ // If home is not set use siteurl.
+ if ( 'home' == $setting && '' == $value )
+ return get_blog_option($blog_id, 'siteurl');
+
+ if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting )
+ $value = preg_replace('|/+$|', '', $value);
+
+ if (! unserialize($value) )
+ $value = stripslashes( $value );
+
+ return apply_filters( 'option_' . $setting, maybe_unserialize($value) );
+}
function add_blog_option( $id, $key, $value ) {
switch_to_blog($id);
add_option( $key, $value );
restore_current_blog();
+ $opt = $id."-".$key."-blog_option";
+ wp_cache_set($opt, $value, 'site-options');
}
function delete_blog_option( $id, $key ) {
switch_to_blog($id);
delete_option( $key );
restore_current_blog();
+ $opt = $id."-".$key."-blog_option";
+ wp_cache_set($opt, '', 'site-options');
}
function update_blog_option( $id, $key, $value, $refresh = true ) {
@@ -310,6 +349,8 @@ function update_blog_option( $id, $key, $value, $refresh = true ) {
restore_current_blog();
if( $refresh == true )
refresh_blog_details( $id );
+ $opt = $id."-".$key."-blog_option";
+ wp_cache_set($opt, $value, 'site-options');
}
function switch_to_blog( $new_blog ) {