Changeset 1322

Show
Ignore:
Timestamp:
06/05/08 17:01:06 (3 months ago)
Author:
donncha
Message:

Cleanup init process
Initialize the object cache sooner so sunrise.php can use it.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/wp-db.php

    r1290 r1322  
    2626        var $prefix = ''; 
    2727        var $ready = false; 
    28  
    29         // Our tables 
     28        var $blogid = 0; 
     29        var $siteid = 0; 
     30 
     31        // Global tables 
     32        var $blogs; 
     33        var $signups; 
     34        var $site; 
     35        var $sitemeta; 
     36        var $users; 
     37        var $usermeta; 
     38        var $sitecategories; 
     39        var $global_tables = array('blogs', 'signups', 'site', 'sitemeta', 'users', 'usermeta', 'sitecategories', 'registration_log', 'blog_versions'); 
     40 
     41        // Blog tables 
    3042        var $posts; 
    31         var $users; 
    3243        var $categories; 
    3344        var $post2cat; 
     
    3647        var $options; 
    3748        var $postmeta; 
    38         var $usermeta; 
    3949        var $terms; 
    4050        var $term_taxonomy; 
    4151        var $term_relationships; 
    42         var $tables = array('users', 'usermeta', 'posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options', 
     52        var $blog_tables = array('posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options', 
    4353                        'postmeta', 'terms', 'term_taxonomy', 'term_relationships'); 
     54 
    4455        var $charset; 
    4556        var $collate; 
    46         var $blog_tables = array('posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options', 'postmeta', 'terms', 'term_taxonomy', 'term_relationships'); 
    47  
    4857 
    4958        /** 
     
    107116 
    108117        function set_prefix($prefix) { 
    109  
    110118                if ( preg_match('|[^a-z0-9_]|i', $prefix) ) 
    111119                        return new WP_Error('invalid_db_prefix', 'Invalid database prefix'); // No gettext here 
    112120 
    113                 $old_prefix = $this->prefix; 
    114                 $this->prefix = $prefix; 
    115  
    116                 foreach ( $this->tables as $table ) 
     121                $old_prefix = $this->base_prefix; 
     122                $this->base_prefix = $prefix; 
     123                foreach ( $this->global_tables as $table ) 
     124                        $this->$table = $prefix . $table; 
     125 
     126                if ( empty($this->blogid) ) 
     127                        return $old_prefix; 
     128 
     129                $this->prefix = $this->base_prefix . $this->blogid . '_'; 
     130 
     131                foreach ( $this->blog_tables as $table ) 
    117132                        $this->$table = $this->prefix . $table; 
    118133 
  • trunk/wp-settings.php

    r1297 r1322  
    202202require (ABSPATH . WPINC . '/compat.php'); 
    203203require (ABSPATH . WPINC . '/functions.php'); 
    204 require (ABSPATH . WPINC . '/classes.php'); 
    205204 
    206205require_wp_db(); 
    207  
     206$wpdb->set_prefix($table_prefix); // set up global tables 
    208207if ( !empty($wpdb->error) ) 
    209208        dead_db(); 
    210209 
    211 $prefix = $wpdb->set_prefix($table_prefix); 
    212  
    213 if ( is_wp_error($prefix) ) 
    214         wp_die('<strong>ERROR</strong>: <code>$table_prefix</code> in <code>wp-config.php</code> can only contain numbers, letters, and underscores.'); 
    215 // Table names. prefix is bare "wp_" 
    216 $wpdb->blogs            = $wpdb->prefix . 'blogs'; 
    217 $wpdb->site             = $wpdb->prefix . 'site'; 
    218 $wpdb->sitemeta         = $wpdb->prefix . 'sitemeta'; 
    219 $wpdb->sitecategories   = $wpdb->prefix . 'sitecategories'; 
    220 $wpdb->signups          = $wpdb->prefix . 'signups'; 
    221 $wpdb->registration_log = $wpdb->prefix . 'registration_log'; 
    222 $wpdb->blog_versions    = $wpdb->prefix . 'blog_versions'; 
     210if ( !defined( 'WP_INSTALLING' ) && file_exists(ABSPATH . 'wp-content/object-cache.php') ) 
     211        require_once (ABSPATH . 'wp-content/object-cache.php'); 
     212else 
     213        require_once (ABSPATH . WPINC . '/cache.php'); 
     214 
     215wp_cache_init(); 
    223216 
    224217if( defined( 'SUNRISE' ) ) 
     
    226219 
    227220require_once ( ABSPATH . 'wpmu-settings.php' ); 
    228 $prefix = $table_prefix; 
    229 $wpdb->prefix           = $table_prefix; // prefix now includes a blog_id 
    230 $wpdb->posts            = $wpdb->prefix . 'posts'; 
    231 $wpdb->categories       = $wpdb->prefix . 'categories'; 
    232 $wpdb->post2cat         = $wpdb->prefix . 'post2cat'; 
    233 $wpdb->comments         = $wpdb->prefix . 'comments'; 
    234 $wpdb->link2cat         = $wpdb->prefix . 'link2cat'; 
    235 $wpdb->links            = $wpdb->prefix . 'links'; 
    236 $wpdb->linkcategories   = $wpdb->prefix . 'linkcategories'; 
    237 $wpdb->options          = $wpdb->prefix . 'options'; 
    238 $wpdb->postmeta         = $wpdb->prefix . 'postmeta'; 
    239 $wpdb->terms            = $wpdb->prefix . 'terms'; 
    240 $wpdb->term_taxonomy    = $wpdb->prefix . 'term_taxonomy'; 
    241 $wpdb->term_relationships = $wpdb->prefix . 'term_relationships'; 
     221$wpdb->blogid           = $current_blog->blog_id; 
    242222$wpdb->siteid           = $current_blog->site_id; 
    243 $wpdb->blogid           = $current_blog->blog_id; 
    244  
     223$wpdb->set_prefix($table_prefix); // set up blog tables 
     224$table_prefix = $table_prefix . $blog_id . '_'; 
     225 
     226wp_cache_init(); // need to init cache again after blog_id is set 
    245227if ( defined('CUSTOM_USER_TABLE') ) 
    246228        $wpdb->users = CUSTOM_USER_TABLE; 
     
    248230        $wpdb->usermeta = CUSTOM_USER_META_TABLE; 
    249231 
    250 if ( !defined( 'WP_INSTALLING' ) && file_exists(ABSPATH . 'wp-content/object-cache.php') ) 
    251         require_once (ABSPATH . 'wp-content/object-cache.php'); 
    252 else 
    253         require_once (ABSPATH . WPINC . '/cache.php'); 
    254  
    255 wp_cache_init(); 
    256  
    257232if( !defined( "UPLOADS" ) ) 
    258233        define( "UPLOADS", "wp-content/blogs.dir/{$wpdb->blogid}/files/" ); 
    259234 
     235if( defined( "SHORTINIT" ) && constant( "SHORTINIT" ) == true ) // stop most of WP being loaded, we just want the basics 
     236        return; 
     237 
     238require (ABSPATH . WPINC . '/classes.php'); 
    260239require (ABSPATH . WPINC . '/plugin.php'); 
    261240require (ABSPATH . WPINC . '/default-filters.php'); 
    262  
    263 if( defined( "SHORTINIT" ) && constant( "SHORTINIT" ) == true ) // stop most of WP being loaded, we just want the basics 
    264         return; 
    265  
    266241include_once(ABSPATH . WPINC . '/streams.php'); 
    267242include_once(ABSPATH . WPINC . '/gettext.php'); 
  • trunk/wpmu-settings.php

    r1274 r1322  
    55// depreciated 
    66$wpmuBaseTablePrefix = $table_prefix; 
    7 $wpdb->base_prefix = $table_prefix; 
    87 
    98$domain = addslashes( $_SERVER['HTTP_HOST'] ); 
     
    209208} 
    210209 
    211 $table_prefix = $table_prefix . $blog_id . '_'; 
    212  
    213210?>