diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-05-23 17:31:51 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-05-23 17:31:51 +0000 |
commit | 1c4354fd3d0fb51f54899cf4599aef5e9b7491ea (patch) | |
tree | df4cf1f71597a0f0e4c3db9e454e18d57e27db6c | |
parent | b7a46d708e56cc838ec6faecd2fac2897650c43b (diff) | |
download | wordpress-mu-1c4354fd3d0fb51f54899cf4599aef5e9b7491ea.tar.gz wordpress-mu-1c4354fd3d0fb51f54899cf4599aef5e9b7491ea.tar.xz wordpress-mu-1c4354fd3d0fb51f54899cf4599aef5e9b7491ea.zip |
Experimental: warn if blog_id is changed without switch_to_blog() being called because it results in cache pollution
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1310 7be80a69-a1ef-0310-a953-fb0f7c49ff36
-rw-r--r-- | wp-includes/functions.php | 15 | ||||
-rw-r--r-- | wp-includes/wpmu-functions.php | 6 |
2 files changed, 16 insertions, 5 deletions
diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 51445a1..e12e2aa 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -203,9 +203,18 @@ function get_option( $setting ) { return $pre; if ( $switched != false || defined('WP_INSTALLING') != false ) { - wp_cache_delete($setting, 'options'); - wp_cache_delete('notoptions', 'options'); - wp_cache_delete('alloptions', 'options'); + global $blog_id, $switched_to; + if( $switched_to != $blog_id && function_exists('error_log') ) { + $msg = "{$_SERVER[ 'HTTP_HOST' ]}{$_SERVER[ 'REQUEST_URI' ]} blog_id changed without calling switch_to_blog(). Current value: $blog_id"; + if( defined( 'ERRORLOGFILE' ) ) { + error_log( $msg, 3, CONSTANT( 'ERRORLOGFILE' ) ); + } else { + error_log( $msg ); + } + } + //wp_cache_delete($setting, '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 804a273..27bc088 100644 --- a/wp-includes/wpmu-functions.php +++ b/wp-includes/wpmu-functions.php @@ -322,7 +322,7 @@ function update_blog_option( $id, $key, $value, $refresh = true ) { } function switch_to_blog( $new_blog ) { - global $wpdb, $table_prefix, $blog_id, $switched, $switched_stack, $wp_roles, $current_user, $wp_object_cache; + global $wpdb, $table_prefix, $blog_id, $switched, $switched_stack, $wp_roles, $current_user, $wp_object_cache, $switched_to; if ( empty($new_blog) ) return; @@ -339,6 +339,7 @@ function switch_to_blog( $new_blog ) { $table_prefix = $wpdb->prefix; $prev_blog_id = $blog_id; $blog_id = $new_blog; + $switched_to = $blog_id; if( is_object( $wp_roles ) ) { $wpdb->suppress_errors(); @@ -354,7 +355,7 @@ function switch_to_blog( $new_blog ) { } function restore_current_blog() { - global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $current_user, $wp_object_cache; + global $table_prefix, $wpdb, $blog_id, $switched, $switched_stack, $wp_roles, $current_user, $wp_object_cache, $switched_to; if ( !$switched ) return; @@ -367,6 +368,7 @@ function restore_current_blog() { $prev_blog_id = $blog_id; $blog_id = $blog; $table_prefix = $wpdb->prefix; + $switched_to = $blog_id; if( is_object( $wp_roles ) ) { $wpdb->suppress_errors(); |