From e50b8fa34817396677b399d267fee1b1db9326fa Mon Sep 17 00:00:00 2001 From: wpmuguru Date: Wed, 24 Feb 2010 21:30:13 +0000 Subject: [PATCH] database code cleanup, See #12362 git-svn-id: http://svn.automattic.com/wordpress/trunk@13387 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/ms-settings.php | 2 +- wp-includes/wp-db.php | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/wp-includes/ms-settings.php b/wp-includes/ms-settings.php index f5e5fb5100..9883c4e823 100644 --- a/wp-includes/ms-settings.php +++ b/wp-includes/ms-settings.php @@ -115,7 +115,7 @@ if ( ! $blog_id ) { } } -$wpdb->set_prefix( $table_prefix ); // set up blog tables +$wpdb->set_prefix( $table_prefix, false ); // set DB table prefix $wpdb->set_blog_id( $current_blog->blog_id, $current_blog->site_id ); $table_prefix = $wpdb->get_blog_prefix(); diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 0085900792..168f59ed30 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -548,7 +548,7 @@ class wpdb { * @param string $prefix Alphanumeric name for the new prefix. * @return string|WP_Error Old prefix or WP_Error on error */ - function set_prefix( $prefix ) { + function set_prefix( $prefix, $set_table_names = true ) { if ( preg_match( '|[^a-z0-9_]|i', $prefix ) ) return new WP_Error('invalid_db_prefix', /*WP_I18N_DB_BAD_PREFIX*/'Invalid database prefix'/*/WP_I18N_DB_BAD_PREFIX*/); @@ -560,20 +560,21 @@ class wpdb { $this->base_prefix = $prefix; - foreach ( $this->tables( 'global' ) as $table => $prefixed_table ) - $this->$table = $prefixed_table; + if ( $set_table_names ) { + foreach ( $this->tables( 'global' ) as $table => $prefixed_table ) + $this->$table = $prefixed_table; - if ( defined( 'VHOST' ) && empty( $this->blogid ) ) - return $old_prefix; + if ( defined( 'VHOST' ) && empty( $this->blogid ) ) + return $old_prefix; - $this->prefix = $this->get_blog_prefix( $this->blogid ); + $this->prefix = $this->get_blog_prefix( $this->blogid ); - foreach ( $this->tables( 'blog' ) as $table => $prefixed_table ) - $this->$table = $prefixed_table; - - foreach ( $this->tables( 'old' ) as $table => $prefixed_table ) - $this->$table = $prefixed_table; + foreach ( $this->tables( 'blog' ) as $table => $prefixed_table ) + $this->$table = $prefixed_table; + foreach ( $this->tables( 'old' ) as $table => $prefixed_table ) + $this->$table = $prefixed_table; + } return $old_prefix; }