Use the wpdb method instead of $wpdb->prefix.

props hakre.
fixes #16756.

Built from https://develop.svn.wordpress.org/trunk@25615


git-svn-id: http://core.svn.wordpress.org/trunk@25532 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-09-24 23:41:10 +00:00
parent f41d44f20b
commit 0e620877fd
3 changed files with 12 additions and 11 deletions

View File

@ -95,7 +95,7 @@ class WP_Roles {
*/ */
function _init () { function _init () {
global $wpdb, $wp_user_roles; global $wpdb, $wp_user_roles;
$this->role_key = $wpdb->prefix . 'user_roles'; $this->role_key = $wpdb->get_blog_prefix() . 'user_roles';
if ( ! empty( $wp_user_roles ) ) { if ( ! empty( $wp_user_roles ) ) {
$this->roles = $wp_user_roles; $this->roles = $wp_user_roles;
$this->use_db = false; $this->use_db = false;
@ -131,7 +131,7 @@ class WP_Roles {
global $wpdb, $wp_user_roles; global $wpdb, $wp_user_roles;
// Duplicated from _init() to avoid an extra function call. // Duplicated from _init() to avoid an extra function call.
$this->role_key = $wpdb->prefix . 'user_roles'; $this->role_key = $wpdb->get_blog_prefix() . 'user_roles';
$this->roles = get_option( $this->role_key ); $this->roles = get_option( $this->role_key );
if ( empty( $this->roles ) ) if ( empty( $this->roles ) )
return; return;
@ -709,7 +709,7 @@ class WP_User {
global $wpdb; global $wpdb;
if ( empty($cap_key) ) if ( empty($cap_key) )
$this->cap_key = $wpdb->prefix . 'capabilities'; $this->cap_key = $wpdb->get_blog_prefix() . 'capabilities';
else else
$this->cap_key = $cap_key; $this->cap_key = $cap_key;
@ -859,7 +859,7 @@ class WP_User {
function update_user_level_from_caps() { function update_user_level_from_caps() {
global $wpdb; global $wpdb;
$this->user_level = array_reduce( array_keys( $this->allcaps ), array( $this, 'level_reduction' ), 0 ); $this->user_level = array_reduce( array_keys( $this->allcaps ), array( $this, 'level_reduction' ), 0 );
update_user_meta( $this->ID, $wpdb->prefix . 'user_level', $this->user_level ); update_user_meta( $this->ID, $wpdb->get_blog_prefix() . 'user_level', $this->user_level );
} }
/** /**
@ -901,7 +901,7 @@ class WP_User {
global $wpdb; global $wpdb;
$this->caps = array(); $this->caps = array();
delete_user_meta( $this->ID, $this->cap_key ); delete_user_meta( $this->ID, $this->cap_key );
delete_user_meta( $this->ID, $wpdb->prefix . 'user_level' ); delete_user_meta( $this->ID, $wpdb->get_blog_prefix() . 'user_level' );
$this->get_role_caps(); $this->get_role_caps();
} }

View File

@ -498,7 +498,7 @@ function switch_to_blog( $new_blog, $deprecated = null ) {
} }
$wpdb->set_blog_id( $new_blog ); $wpdb->set_blog_id( $new_blog );
$GLOBALS['table_prefix'] = $wpdb->prefix; $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix();
$prev_blog_id = $GLOBALS['blog_id']; $prev_blog_id = $GLOBALS['blog_id'];
$GLOBALS['blog_id'] = $new_blog; $GLOBALS['blog_id'] = $new_blog;
@ -561,7 +561,7 @@ function restore_current_blog() {
$wpdb->set_blog_id( $blog ); $wpdb->set_blog_id( $blog );
$prev_blog_id = $GLOBALS['blog_id']; $prev_blog_id = $GLOBALS['blog_id'];
$GLOBALS['blog_id'] = $blog; $GLOBALS['blog_id'] = $blog;
$GLOBALS['table_prefix'] = $wpdb->prefix; $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix();
if ( function_exists( 'wp_cache_switch_to_blog' ) ) { if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
wp_cache_switch_to_blog( $blog ); wp_cache_switch_to_blog( $blog );

View File

@ -248,8 +248,9 @@ function get_user_option( $option, $user = 0, $deprecated = '' ) {
if ( ! $user = get_userdata( $user ) ) if ( ! $user = get_userdata( $user ) )
return false; return false;
if ( $user->has_prop( $wpdb->prefix . $option ) ) // Blog specific $prefix = $wpdb->get_blog_prefix();
$result = $user->get( $wpdb->prefix . $option ); if ( $user->has_prop( $prefix . $option ) ) // Blog specific
$result = $user->get( $prefix . $option );
elseif ( $user->has_prop( $option ) ) // User specific and cross-blog elseif ( $user->has_prop( $option ) ) // User specific and cross-blog
$result = $user->get( $option ); $result = $user->get( $option );
else else
@ -280,7 +281,7 @@ function update_user_option( $user_id, $option_name, $newvalue, $global = false
global $wpdb; global $wpdb;
if ( !$global ) if ( !$global )
$option_name = $wpdb->prefix . $option_name; $option_name = $wpdb->get_blog_prefix() . $option_name;
return update_user_meta( $user_id, $option_name, $newvalue ); return update_user_meta( $user_id, $option_name, $newvalue );
} }
@ -304,7 +305,7 @@ function delete_user_option( $user_id, $option_name, $global = false ) {
global $wpdb; global $wpdb;
if ( !$global ) if ( !$global )
$option_name = $wpdb->prefix . $option_name; $option_name = $wpdb->get_blog_prefix() . $option_name;
return delete_user_meta( $user_id, $option_name ); return delete_user_meta( $user_id, $option_name );
} }