From ea7e2672ca23b81d1f79f60e077929433fe9ae77 Mon Sep 17 00:00:00 2001 From: donncha Date: Thu, 5 Jun 2008 17:01:06 +0000 Subject: Cleanup init process Initialize the object cache sooner so sunrise.php can use it. git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1322 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-includes/wp-db.php | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'wp-includes/wp-db.php') diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index bbef0cf..b7fb414 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -25,26 +25,35 @@ class wpdb { var $queries; var $prefix = ''; var $ready = false; + var $blogid = 0; + var $siteid = 0; + + // Global tables + var $blogs; + var $signups; + var $site; + var $sitemeta; + var $users; + var $usermeta; + var $sitecategories; + var $global_tables = array('blogs', 'signups', 'site', 'sitemeta', 'users', 'usermeta', 'sitecategories', 'registration_log', 'blog_versions'); - // Our tables + // Blog tables var $posts; - var $users; var $categories; var $post2cat; var $comments; var $links; var $options; var $postmeta; - var $usermeta; var $terms; var $term_taxonomy; var $term_relationships; - var $tables = array('users', 'usermeta', 'posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options', + var $blog_tables = array('posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options', 'postmeta', 'terms', 'term_taxonomy', 'term_relationships'); + var $charset; var $collate; - var $blog_tables = array('posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options', 'postmeta', 'terms', 'term_taxonomy', 'term_relationships'); - /** * Connects to the database server and selects a database @@ -106,14 +115,20 @@ class wpdb { } function set_prefix($prefix) { - if ( preg_match('|[^a-z0-9_]|i', $prefix) ) return new WP_Error('invalid_db_prefix', 'Invalid database prefix'); // No gettext here - $old_prefix = $this->prefix; - $this->prefix = $prefix; + $old_prefix = $this->base_prefix; + $this->base_prefix = $prefix; + foreach ( $this->global_tables as $table ) + $this->$table = $prefix . $table; + + if ( empty($this->blogid) ) + return $old_prefix; - foreach ( $this->tables as $table ) + $this->prefix = $this->base_prefix . $this->blogid . '_'; + + foreach ( $this->blog_tables as $table ) $this->$table = $this->prefix . $table; if ( defined('CUSTOM_USER_TABLE') ) -- cgit