<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[12885] trunk: rearrage multisite initialization,
  remove deprecated $wpmuBaseTablePrefix, props nacin, see #11881</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12885">12885</a></dd>
<dt>Author</dt> <dd>wpmuguru</dd>
<dt>Date</dt> <dd>2010-01-28 16:09:52 +0000 (Thu, 28 Jan 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>rearrage multisite initialization, remove deprecated $wpmuBaseTablePrefix, props nacin, see <a href="http://trac.wordpress.org/ticket/11881">#11881</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesloadphp">trunk/wp-includes/load.php</a></li>
<li><a href="#trunkwpincludesmsdeprecatedphp">trunk/wp-includes/ms-deprecated.php</a></li>
<li><a href="#trunkwpincludesmsloadphp">trunk/wp-includes/ms-load.php</a></li>
<li><a href="#trunkwpincludesmssettingsphp">trunk/wp-includes/ms-settings.php</a></li>
<li><a href="#trunkwpsettingsphp">trunk/wp-settings.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesloadphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/load.php (12884 => 12885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/load.php        2010-01-28 15:29:23 UTC (rev 12884)
+++ trunk/wp-includes/load.php        2010-01-28 16:09:52 UTC (rev 12885)
</span><span class="lines">@@ -1,5 +1,4 @@
</span><span class="cx"> &lt;?php
</span><del>-
</del><span class="cx"> /**
</span><span class="cx">  * These functions are needed to load WordPress.
</span><span class="cx">  *
</span></span></pre></div>
<a id="trunkwpincludesmsdeprecatedphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-deprecated.php (12884 => 12885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-deprecated.php        2010-01-28 15:29:23 UTC (rev 12884)
+++ trunk/wp-includes/ms-deprecated.php        2010-01-28 16:09:52 UTC (rev 12885)
</span><span class="lines">@@ -14,13 +14,13 @@
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * @since unknown
</span><del>- * @deprecated 3.0
</del><ins>+ * @deprecated 3.0.0
</ins><span class="cx">  * @deprecated Use wp_generate_password()
</span><span class="cx">  * @see wp_generate_password()
</span><span class="cx">  */
</span><span class="cx"> function generate_random_password( $len = 8 ) {
</span><span class="cx">         _deprecated_function( __FUNCTION__, '3.0', 'wp_generate_password()' );
</span><del>-        return wp_generate_password($len);
</del><ins>+        return wp_generate_password( $len );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -32,8 +32,8 @@
</span><span class="cx">  * This function must reside in a file included only if is_multisite() due to
</span><span class="cx">  * legacy function_exists() checks to determine if multisite is enabled.
</span><span class="cx">  *
</span><del>- * @since unknown
- * @deprecated 3.0
</del><ins>+ * @since MU
+ * @deprecated 3.0.0
</ins><span class="cx">  * @deprecated Use is_super_admin()
</span><span class="cx">  * @see is_super_admin()
</span><span class="cx">  * @see is_multisite()
</span><span class="lines">@@ -56,13 +56,16 @@
</span><span class="cx">         return is_super_admin( $user_id );
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-if ( !function_exists('graceful_fail') ) :
</del><ins>+if ( !function_exists( 'graceful_fail' ) ) :
</ins><span class="cx"> /**
</span><del>- * @deprecated 3.0
</del><ins>+ * @since MU
+ * @deprecated 3.0.0
+ * @deprecated Use wp_die()
+ * @see wp_die()
</ins><span class="cx">  */
</span><span class="cx"> function graceful_fail( $message ) {
</span><span class="cx">         _deprecated_function( __FUNCTION__, '3.0', 'wp_die()' );
</span><del>-        $message = apply_filters('graceful_fail', $message);
</del><ins>+        $message = apply_filters( 'graceful_fail', $message );
</ins><span class="cx">         $message_template = apply_filters( 'graceful_fail_template',
</span><span class="cx"> '&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
</span><span class="cx"> &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;head profile=&quot;http://gmpg.org/xfn/11&quot;&gt;
</span><span class="lines">@@ -92,41 +95,52 @@
</span><span class="cx"> endif;
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * @deprecated 3.0
</del><ins>+ * @since MU
+ * @deprecated 3.0.0
+ * @deprecated Use $GLOBALS['current_user']-&gt;ID
</ins><span class="cx">  */
</span><span class="cx"> function get_current_user_id() {
</span><del>-        _deprecated_function( __FUNCTION__, '3.0', '' );
-
-        global $current_user;
-        return $current_user-&gt;ID;
</del><ins>+        _deprecated_function( __FUNCTION__, '3.0', '$GLOBALS\'current_user\']-&gt;ID' );
+        return $GLOBALS['current_user']-&gt;ID;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * @deprecated 3.0
</del><ins>+ * @since MU
+ * @deprecated 3.0.0
+ * @deprecated Use get_user_by()
+ * @see get_user_by()
</ins><span class="cx">  */
</span><span class="cx"> function get_user_details( $username ) {
</span><span class="cx">         _deprecated_function( __FUNCTION__, '3.0', 'get_user_by()' );
</span><del>-
</del><span class="cx">         return get_user_by('login', $username);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * @deprecated 3.0
</del><ins>+ * @since MU
+ * @deprecated 3.0.0
+ * @deprecated Use clean_post_cache()
+ * @see clean_post_cache()
</ins><span class="cx">  */
</span><span class="cx"> function clear_global_post_cache( $post_id ) {
</span><del>-        _deprecated_function( __FUNCTION__, '3.0', 'clean_post_cache' );
</del><ins>+        _deprecated_function( __FUNCTION__, '3.0', 'clean_post_cache()' );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * @deprecated 3.0
</del><ins>+ * @since MU
+ * @deprecated 3.0.0
+ * @deprecated Use is_main_site()
+ * @see is_main_site()
</ins><span class="cx">  */
</span><span class="cx"> function is_main_blog() {
</span><del>-        _deprecated_function( __FUNCTION__, '3.0', 'is_main_site' );
</del><ins>+        _deprecated_function( __FUNCTION__, '3.0', 'is_main_site()' );
</ins><span class="cx">         return is_main_site();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * @deprecated 3.0
</del><ins>+ * @since MU
+ * @deprecated 3.0.0
+ * @deprecated Use is_email()
+ * @see is_email()
</ins><span class="cx">  */
</span><span class="cx"> function validate_email( $email, $check_domain = true) {
</span><span class="cx">         _deprecated_function( __FUNCTION__, '3.0', 'is_email()' );
</span></span></pre></div>
<a id="trunkwpincludesmsloadphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-load.php (12884 => 12885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-load.php        2010-01-28 15:29:23 UTC (rev 12884)
+++ trunk/wp-includes/ms-load.php        2010-01-28 16:09:52 UTC (rev 12885)
</span><span class="lines">@@ -1,44 +1,27 @@
</span><span class="cx"> &lt;?php
</span><span class="cx"> /**
</span><del>- * Used to setup and fix common variables and include
- * the WordPress procedural and class library.
</del><ins>+ * These functions are needed to load Multisite.
</ins><span class="cx">  *
</span><del>- * You should not have to change this file and allows
- * for some configuration in wp-config.php.
</del><ins>+ * @since 3.0.0
</ins><span class="cx">  *
</span><ins>+ * @package WordPress
+ * @subpackage Multisite
+ */
+
+/**
+ * Whether a subdomain configuration is enabled
+ *
</ins><span class="cx">  * @since 3.0
</span><span class="cx">  *
</span><del>- * @package WordPress
</del><ins>+ * @return bool True if subdomain configuration is enabled, false otherwise.
</ins><span class="cx">  */
</span><del>-if ( defined( 'SUNRISE' ) )
-        include_once( WP_CONTENT_DIR . '/sunrise.php' );
</del><ins>+function is_subdomain_install() {
+        if ( defined('VHOST') &amp;&amp; VHOST == 'yes' )
+                return true;
</ins><span class="cx"> 
</span><del>-require( ABSPATH . WPINC . '/ms-settings.php' );
-$wpdb-&gt;blogid = $current_blog-&gt;blog_id;
-$wpdb-&gt;siteid = $current_blog-&gt;site_id;
-$wpdb-&gt;set_prefix($table_prefix); // set up blog tables
-$table_prefix = $wpdb-&gt;get_blog_prefix();
-
-// Fix empty PHP_SELF
-$PHP_SELF = $_SERVER['PHP_SELF'];
-if ( empty($PHP_SELF) || ( empty($PHP_SELF) &amp;&amp; !is_subdomain_install() &amp;&amp; $current_blog-&gt;path != '/' ) )
-        $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace(&quot;/(\?.*)?$/&quot;,'',$_SERVER[&quot;REQUEST_URI&quot;]);
-
-wp_cache_init(); // need to init cache again after blog_id is set
-if ( function_exists('wp_cache_add_global_groups') ) { // need to add these again. Yes, it's an ugly hack
-        wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss'));
-        wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
</del><ins>+        return false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-if ( !defined( 'UPLOADBLOGSDIR' ) )
-        define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir' );
-
-if ( !defined( 'UPLOADS' ) )
-        define( 'UPLOADS', UPLOADBLOGSDIR . &quot;/{$wpdb-&gt;blogid}/files/&quot; );
-
-if ( !defined( 'BLOGUPLOADDIR' ) )
-        define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . &quot;/blogs.dir/{$wpdb-&gt;blogid}/files/&quot; );
-
</del><span class="cx"> function ms_network_settings() {
</span><span class="cx">         global $wpdb, $current_site, $cookiehash;
</span><span class="cx"> 
</span><span class="lines">@@ -112,38 +95,130 @@
</span><span class="cx">         return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function ms_network_cookies() {
-        global $current_site;
-        /**
-         * It is possible to define this in wp-config.php
-         * @since 1.2.0
-         */
-        if ( !defined( 'COOKIEPATH' ) )
-                        define( 'COOKIEPATH', $current_site-&gt;path );
</del><ins>+function get_current_site_name( $current_site ) {
+        global $wpdb;
+        $current_site-&gt;site_name = wp_cache_get( $current_site-&gt;id . ':current_site_name', &quot;site-options&quot; );
+        if ( !$current_site-&gt;site_name ) {
+                $current_site-&gt;site_name = $wpdb-&gt;get_var( $wpdb-&gt;prepare( &quot;SELECT meta_value FROM $wpdb-&gt;sitemeta WHERE site_id = %d AND meta_key = 'site_name'&quot;, $current_site-&gt;id ) );
+                if ( $current_site-&gt;site_name == null )
+                        $current_site-&gt;site_name = ucfirst( $current_site-&gt;domain );
+                wp_cache_set( $current_site-&gt;id . ':current_site_name', $current_site-&gt;site_name, 'site-options');
+        }
+        return $current_site;
+}
</ins><span class="cx"> 
</span><del>-        /**
-         * It is possible to define this in wp-config.php
-         * @since 1.5.0
-         */
-        if ( !defined( 'SITECOOKIEPATH' ) )
-                        define( 'SITECOOKIEPATH', $current_site-&gt;path );
</del><ins>+function wpmu_current_site() {
+        global $wpdb, $current_site, $domain, $path, $sites, $cookie_domain;
+        if ( defined( 'DOMAIN_CURRENT_SITE' ) &amp;&amp; defined( 'PATH_CURRENT_SITE' ) ) {
+                $current_site-&gt;id = (defined( 'SITE_ID_CURRENT_SITE' ) ? constant('SITE_ID_CURRENT_SITE') : 1);
+                $current_site-&gt;domain = DOMAIN_CURRENT_SITE;
+                $current_site-&gt;path   = $path = PATH_CURRENT_SITE;
+                if ( defined( 'BLOGID_CURRENT_SITE' ) )
+                        $current_site-&gt;blog_id = BLOGID_CURRENT_SITE;
+                if ( DOMAIN_CURRENT_SITE == $domain )
+                        $current_site-&gt;cookie_domain = $cookie_domain;
+                elseif ( substr( $current_site-&gt;domain, 0, 4 ) == 'www.' )
+                        $current_site-&gt;cookie_domain = substr( $current_site-&gt;domain, 4 );
+                else
+                        $current_site-&gt;cookie_domain = $current_site-&gt;domain;
</ins><span class="cx"> 
</span><del>-        /**
-         * It is possible to define this in wp-config.php
-         * @since 2.6.0
-         */
-        if ( !defined( 'ADMIN_COOKIE_PATH' ) ) {
-                        if( !is_subdomain_install() ) {
-                                        define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH );
</del><ins>+                return $current_site;
+        }
+
+        $current_site = wp_cache_get( &quot;current_site&quot;, &quot;site-options&quot; );
+        if ( $current_site )
+                return $current_site;
+
+        $wpdb-&gt;suppress_errors();
+        $sites = $wpdb-&gt;get_results( &quot;SELECT * FROM $wpdb-&gt;site&quot; ); // usually only one site
+        if ( count( $sites ) == 1 ) {
+                $current_site = $sites[0];
+                $path = $current_site-&gt;path;
+                $current_site-&gt;blog_id = $wpdb-&gt;get_var( &quot;SELECT blog_id FROM {$wpdb-&gt;blogs} WHERE domain='{$current_site-&gt;domain}' AND path='{$current_site-&gt;path}'&quot; );
+                $current_site = get_current_site_name( $current_site );
+                if ( substr( $current_site-&gt;domain, 0, 4 ) == 'www.' )
+                        $current_site-&gt;cookie_domain = substr( $current_site-&gt;domain, 4 );
+                wp_cache_set( &quot;current_site&quot;, $current_site, &quot;site-options&quot; );
+                return $current_site;
+        }
+        $path = substr( $_SERVER[ 'REQUEST_URI' ], 0, 1 + strpos( $_SERVER[ 'REQUEST_URI' ], '/', 1 ) );
+
+        if ( $domain == $cookie_domain )
+                $current_site = $wpdb-&gt;get_row( $wpdb-&gt;prepare(&quot;SELECT * FROM $wpdb-&gt;site WHERE domain = %s AND path = %s&quot;, $domain, $path ) );
+        else
+                $current_site = $wpdb-&gt;get_row( $wpdb-&gt;prepare(&quot;SELECT * FROM $wpdb-&gt;site WHERE domain IN ( %s, %s ) AND path = %s ORDER BY CHAR_LENGTH( domain ) DESC LIMIT 1&quot;, $domain, $cookie_domain, $path ) );
+        if ( $current_site == null ) {
+                if ( $domain == $cookie_domain )
+                        $current_site = $wpdb-&gt;get_row( $wpdb-&gt;prepare(&quot;SELECT * FROM $wpdb-&gt;site WHERE domain = %s AND path='/'&quot;, $domain ) );
+                else
+                        $current_site = $wpdb-&gt;get_row( $wpdb-&gt;prepare(&quot;SELECT * FROM $wpdb-&gt;site WHERE domain IN ( %s, %s ) AND path = '/' ORDER BY CHAR_LENGTH( domain ) DESC LIMIT 1&quot;, $domain, $cookie_domain, $path ) );
+        }
+        if ( $current_site != null ) {
+                $path = $current_site-&gt;path;
+                $current_site-&gt;cookie_domain = $cookie_domain;
+                return $current_site;
+        } elseif ( is_subdomain_install() ) {
+                $sitedomain = substr( $domain, 1 + strpos( $domain, '.' ) );
+                $current_site = $wpdb-&gt;get_row( $wpdb-&gt;prepare(&quot;SELECT * FROM $wpdb-&gt;site WHERE domain = %s AND path = %s&quot;, $sitedomain, $path) );
+                if ( $current_site != null ) {
+                        $current_site-&gt;cookie_domain = $current_site-&gt;domain;
+                        return $current_site;
+                }
+                $current_site = $wpdb-&gt;get_row( $wpdb-&gt;prepare(&quot;SELECT * FROM $wpdb-&gt;site WHERE domain = %s AND path='/'&quot;, $sitedomain) );
+                if ( $current_site == null &amp;&amp; defined( &quot;WP_INSTALLING&quot; ) == false ) {
+                        if ( count( $sites ) == 1 ) {
+                                $current_site = $sites[0];
+                                die( &quot;That blog does not exist. Please try &lt;a href='http://{$current_site-&gt;domain}{$current_site-&gt;path}'&gt;http://{$current_site-&gt;domain}{$current_site-&gt;path}&lt;/a&gt;&quot; );
</ins><span class="cx">                         } else {
</span><del>-                                        define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
</del><ins>+                                die( &quot;No WPMU site defined on this host. If you are the owner of this site, please check &lt;a href='http://codex.wordpress.org/Debugging_WPMU'&gt;Debugging WPMU&lt;/a&gt; for further assistance.&quot; );
</ins><span class="cx">                         }
</span><ins>+                } else {
+                        $path = '/';
+                }
+        } elseif ( defined( &quot;WP_INSTALLING&quot; ) == false ) {
+                if ( count( $sites ) == 1 ) {
+                        $current_site = $sites[0];
+                        die( &quot;That blog does not exist. Please try &lt;a href='http://{$current_site-&gt;domain}{$current_site-&gt;path}'&gt;http://{$current_site-&gt;domain}{$current_site-&gt;path}&lt;/a&gt;&quot; );
+                } else {
+                        die( &quot;No WPMU site defined on this host. If you are the owner of this site, please check &lt;a href='http://codex.wordpress.org/Debugging_WPMU'&gt;Debugging WPMU&lt;/a&gt; for further assistance.&quot; );
+                }
+        } else {
+                $path = '/';
</ins><span class="cx">         }
</span><del>-        /**
-         * It is possible to define this in wp-config.php
-         * @since 2.0.0
-         */
-        if ( !defined('COOKIE_DOMAIN') )
-                        define('COOKIE_DOMAIN', '.' . $current_site-&gt;cookie_domain);
</del><ins>+        return $current_site;
</ins><span class="cx"> }
</span><ins>+
+function is_installed() {
+        global $wpdb, $domain, $path;
+        $base = stripslashes( $base );
+        if ( defined( &quot;WP_INSTALLING&quot; ) == false ) {
+                $check = $wpdb-&gt;get_results( &quot;SELECT * FROM $wpdb-&gt;site&quot; );
+                $msg = &quot;If your blog does not display, please contact the owner of this site.&lt;br /&gt;&lt;br /&gt;If you are the owner of this site please check that MySQL is running properly and all tables are error free.&lt;br /&gt;&lt;br /&gt;&quot;;
+                if ( $check == false ) {
+                        $msg .= &quot;&lt;strong&gt;Database Tables Missing.&lt;/strong&gt;&lt;br /&gt;Database tables are missing. This means that MySQL is either not running, WPMU was not installed properly, or someone deleted {$wpdb-&gt;site}. You really &lt;em&gt;should&lt;/em&gt; look at your database now.&lt;br /&gt;&quot;;
+                } else {
+                        $msg .= '&lt;strong&gt;Could Not Find Blog!&lt;/strong&gt;&lt;br /&gt;';
+                        $msg .= &quot;Searched for &lt;em&gt;&quot; . $domain . $path . &quot;&lt;/em&gt; in &quot; . DB_NAME . &quot;::&quot; . $wpdb-&gt;blogs . &quot; table. Is that right?&lt;br /&gt;&quot;;
+                }
+                $msg .= &quot;&lt;br /&gt;\n&lt;h1&gt;What do I do now?&lt;/h1&gt;&quot;;
+                $msg .= &quot;Read the &lt;a target='_blank' href='http://codex.wordpress.org/Debugging_WPMU'&gt;bug report&lt;/a&gt; page. Some of the guidelines there may help you figure out what went wrong.&lt;br /&gt;&quot;;
+                $msg .= &quot;If you're still stuck with this message, then check that your database contains the following tables:&lt;ul&gt;
+                        &lt;li&gt; $wpdb-&gt;blogs &lt;/li&gt;
+                        &lt;li&gt; $wpdb-&gt;users &lt;/li&gt;
+                        &lt;li&gt; $wpdb-&gt;usermeta &lt;/li&gt;
+                        &lt;li&gt; $wpdb-&gt;site &lt;/li&gt;
+                        &lt;li&gt; $wpdb-&gt;sitemeta &lt;/li&gt;
+                        &lt;li&gt; $wpdb-&gt;sitecategories &lt;/li&gt;
+                        &lt;/ul&gt;&quot;;
+                $msg .= &quot;If you suspect a problem please report it to the support forums but you must include the information asked for in the &lt;a href='http://codex.wordpress.org/Debugging_WPMU'&gt;WPMU bug reporting guidelines&lt;/a&gt;!&lt;br /&gt;&lt;br /&gt;&quot;;
+                if ( is_file( 'release-info.txt' ) ) {
+                        $msg .= 'Your bug report must include the following text: &quot;';
+                        $info = file( 'release-info.txt' );
+                        $msg .= $info[ 4 ] . '&quot;';
+                }
+
+                die( &quot;&lt;h1&gt;Fatal Error&lt;/h1&gt; &quot; . $msg );
+        }
+}
+
</ins><span class="cx"> ?&gt;
</span></span></pre></div>
<a id="trunkwpincludesmssettingsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-settings.php (12884 => 12885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-settings.php        2010-01-28 15:29:23 UTC (rev 12884)
+++ trunk/wp-includes/ms-settings.php        2010-01-28 16:09:52 UTC (rev 12885)
</span><span class="lines">@@ -1,25 +1,24 @@
</span><span class="cx"> &lt;?php
</span><del>-
</del><span class="cx"> /**
</span><del>- * Whether a subdomain configuration is enabled
</del><ins>+ * Used to setup and fix common variables and include
+ * the Multisite procedural and class library.
</ins><span class="cx">  *
</span><del>- * @since 3.0
</del><ins>+ * Allows for some configuration in wp-config.php (see ms-default-constants.php)
</ins><span class="cx">  *
</span><del>- * @return bool True if subdomain configuration is enabled, false otherwise.
</del><ins>+ * @package WordPress
+ * @subpackage Multisite
</ins><span class="cx">  */
</span><del>-function is_subdomain_install() {
-        if ( defined('VHOST') &amp;&amp; VHOST == 'yes' )
-                return true;
</del><span class="cx"> 
</span><del>-        return false;
-}
</del><ins>+/** Include Multisite initialization functions */
+require( ABSPATH . WPINC . '/ms-load.php' );
+require( ABSPATH . WPINC . '/ms-default-constants.php' );
</ins><span class="cx"> 
</span><ins>+if ( defined( 'SUNRISE' ) )
+        include_once( WP_CONTENT_DIR . '/sunrise.php' );
+
</ins><span class="cx"> if ( isset( $current_site ) &amp;&amp; isset( $current_blog ) )
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-// deprecated
-$wpmuBaseTablePrefix = $table_prefix;
-
</del><span class="cx"> $domain = addslashes( $_SERVER['HTTP_HOST'] );
</span><span class="cx"> if ( strpos( $domain, ':' ) ) {
</span><span class="cx">         if ( substr( $domain, -3 ) == ':80' ) {
</span><span class="lines">@@ -45,99 +44,6 @@
</span><span class="cx"> $path = str_replace ( '/wp-admin/', '/', $path );
</span><span class="cx"> $path = preg_replace( '|(/[a-z0-9-]+?/).*|', '$1', $path );
</span><span class="cx"> 
</span><del>-function get_current_site_name( $current_site ) {
-        global $wpdb;
-        $current_site-&gt;site_name = wp_cache_get( $current_site-&gt;id . ':current_site_name', &quot;site-options&quot; );
-        if ( !$current_site-&gt;site_name ) {
-                $current_site-&gt;site_name = $wpdb-&gt;get_var( $wpdb-&gt;prepare( &quot;SELECT meta_value FROM $wpdb-&gt;sitemeta WHERE site_id = %d AND meta_key = 'site_name'&quot;, $current_site-&gt;id ) );
-                if ( $current_site-&gt;site_name == null )
-                        $current_site-&gt;site_name = ucfirst( $current_site-&gt;domain );
-                wp_cache_set( $current_site-&gt;id . ':current_site_name', $current_site-&gt;site_name, 'site-options');
-        }
-        return $current_site;
-}
-
-function wpmu_current_site() {
-        global $wpdb, $current_site, $domain, $path, $sites, $cookie_domain;
-        if ( defined( 'DOMAIN_CURRENT_SITE' ) &amp;&amp; defined( 'PATH_CURRENT_SITE' ) ) {
-                $current_site-&gt;id = (defined( 'SITE_ID_CURRENT_SITE' ) ? constant('SITE_ID_CURRENT_SITE') : 1);
-                $current_site-&gt;domain = DOMAIN_CURRENT_SITE;
-                $current_site-&gt;path   = $path = PATH_CURRENT_SITE;
-                if ( defined( 'BLOGID_CURRENT_SITE' ) )
-                        $current_site-&gt;blog_id = BLOGID_CURRENT_SITE;
-                if ( DOMAIN_CURRENT_SITE == $domain )
-                        $current_site-&gt;cookie_domain = $cookie_domain;
-                elseif ( substr( $current_site-&gt;domain, 0, 4 ) == 'www.' )
-                        $current_site-&gt;cookie_domain = substr( $current_site-&gt;domain, 4 );
-                else
-                        $current_site-&gt;cookie_domain = $current_site-&gt;domain;
-
-                return $current_site;
-        }
-
-        $current_site = wp_cache_get( &quot;current_site&quot;, &quot;site-options&quot; );
-        if ( $current_site )
-                return $current_site;
-
-        $wpdb-&gt;suppress_errors();
-        $sites = $wpdb-&gt;get_results( &quot;SELECT * FROM $wpdb-&gt;site&quot; ); // usually only one site
-        if ( count( $sites ) == 1 ) {
-                $current_site = $sites[0];
-                $path = $current_site-&gt;path;
-                $current_site-&gt;blog_id = $wpdb-&gt;get_var( &quot;SELECT blog_id FROM {$wpdb-&gt;blogs} WHERE domain='{$current_site-&gt;domain}' AND path='{$current_site-&gt;path}'&quot; );
-                $current_site = get_current_site_name( $current_site );
-                if ( substr( $current_site-&gt;domain, 0, 4 ) == 'www.' )
-                        $current_site-&gt;cookie_domain = substr( $current_site-&gt;domain, 4 );
-                wp_cache_set( &quot;current_site&quot;, $current_site, &quot;site-options&quot; );
-                return $current_site;
-        }
-        $path = substr( $_SERVER[ 'REQUEST_URI' ], 0, 1 + strpos( $_SERVER[ 'REQUEST_URI' ], '/', 1 ) );
-
-        if ( $domain == $cookie_domain )
-                $current_site = $wpdb-&gt;get_row( $wpdb-&gt;prepare(&quot;SELECT * FROM $wpdb-&gt;site WHERE domain = %s AND path = %s&quot;, $domain, $path ) );
-        else
-                $current_site = $wpdb-&gt;get_row( $wpdb-&gt;prepare(&quot;SELECT * FROM $wpdb-&gt;site WHERE domain IN ( %s, %s ) AND path = %s ORDER BY CHAR_LENGTH( domain ) DESC LIMIT 1&quot;, $domain, $cookie_domain, $path ) );
-        if ( $current_site == null ) {
-                if ( $domain == $cookie_domain )
-                        $current_site = $wpdb-&gt;get_row( $wpdb-&gt;prepare(&quot;SELECT * FROM $wpdb-&gt;site WHERE domain = %s AND path='/'&quot;, $domain ) );
-                else
-                        $current_site = $wpdb-&gt;get_row( $wpdb-&gt;prepare(&quot;SELECT * FROM $wpdb-&gt;site WHERE domain IN ( %s, %s ) AND path = '/' ORDER BY CHAR_LENGTH( domain ) DESC LIMIT 1&quot;, $domain, $cookie_domain, $path ) );
-        }
-        if ( $current_site != null ) {
-                $path = $current_site-&gt;path;
-                $current_site-&gt;cookie_domain = $cookie_domain;
-                return $current_site;
-        } elseif ( is_subdomain_install() ) {
-                $sitedomain = substr( $domain, 1 + strpos( $domain, '.' ) );
-                $current_site = $wpdb-&gt;get_row( $wpdb-&gt;prepare(&quot;SELECT * FROM $wpdb-&gt;site WHERE domain = %s AND path = %s&quot;, $sitedomain, $path) );
-                if ( $current_site != null ) {
-                        $current_site-&gt;cookie_domain = $current_site-&gt;domain;
-                        return $current_site;
-                }
-                $current_site = $wpdb-&gt;get_row( $wpdb-&gt;prepare(&quot;SELECT * FROM $wpdb-&gt;site WHERE domain = %s AND path='/'&quot;, $sitedomain) );
-                if ( $current_site == null &amp;&amp; defined( &quot;WP_INSTALLING&quot; ) == false ) {
-                        if ( count( $sites ) == 1 ) {
-                                $current_site = $sites[0];
-                                die( &quot;That blog does not exist. Please try &lt;a href='http://{$current_site-&gt;domain}{$current_site-&gt;path}'&gt;http://{$current_site-&gt;domain}{$current_site-&gt;path}&lt;/a&gt;&quot; );
-                        } else {
-                                die( &quot;No WPMU site defined on this host. If you are the owner of this site, please check &lt;a href='http://codex.wordpress.org/Debugging_WPMU'&gt;Debugging WPMU&lt;/a&gt; for further assistance.&quot; );
-                        }
-                } else {
-                        $path = '/';
-                }
-        } elseif ( defined( &quot;WP_INSTALLING&quot; ) == false ) {
-                if ( count( $sites ) == 1 ) {
-                        $current_site = $sites[0];
-                        die( &quot;That blog does not exist. Please try &lt;a href='http://{$current_site-&gt;domain}{$current_site-&gt;path}'&gt;http://{$current_site-&gt;domain}{$current_site-&gt;path}&lt;/a&gt;&quot; );
-                } else {
-                        die( &quot;No WPMU site defined on this host. If you are the owner of this site, please check &lt;a href='http://codex.wordpress.org/Debugging_WPMU'&gt;Debugging WPMU&lt;/a&gt; for further assistance.&quot; );
-                }
-        } else {
-                $path = '/';
-        }
-        return $current_site;
-}
-
</del><span class="cx"> $current_site = wpmu_current_site();
</span><span class="cx"> if ( !isset( $current_site-&gt;blog_id ) )
</span><span class="cx">         $current_site-&gt;blog_id = $wpdb-&gt;get_var( &quot;SELECT blog_id FROM {$wpdb-&gt;blogs} WHERE domain='{$current_site-&gt;domain}' AND path='{$current_site-&gt;path}'&quot; );
</span><span class="lines">@@ -170,7 +76,8 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-if ( defined( &quot;WP_INSTALLING&quot; ) == false &amp;&amp; is_subdomain_install() &amp;&amp; !is_object( $current_blog ) ) {
</del><ins>+if ( ! defined( 'WP_INSTALLING' ) &amp;&amp; is_subdomain_install() &amp;&amp; !is_object( $current_blog ) ) {
+
</ins><span class="cx">         if ( defined( 'NOBLOGREDIRECT' ) ) {
</span><span class="cx">                 $destination = constant( 'NOBLOGREDIRECT' );
</span><span class="cx">                 if ( $destination == '%siteurl%' )
</span><span class="lines">@@ -184,7 +91,7 @@
</span><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-if ( defined( &quot;WP_INSTALLING&quot; ) == false ) {
</del><ins>+if ( ! defined( 'WP_INSTALLING' ) ) {
</ins><span class="cx">         if ( $current_site &amp;&amp; $current_blog == null ) {
</span><span class="cx">                 if ( $current_site-&gt;domain != $_SERVER[ 'HTTP_HOST' ] ) {
</span><span class="cx">                         header( &quot;Location: http://&quot; . $current_site-&gt;domain . $current_site-&gt;path );
</span><span class="lines">@@ -235,37 +142,22 @@
</span><span class="cx">         // This just means the blog shouldn't show up in google, etc. Only to registered members
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function is_installed() {
-        global $wpdb, $domain, $path;
-        $base = stripslashes( $base );
-        if ( defined( &quot;WP_INSTALLING&quot; ) == false ) {
-                $check = $wpdb-&gt;get_results( &quot;SELECT * FROM $wpdb-&gt;site&quot; );
-                $msg = &quot;If your blog does not display, please contact the owner of this site.&lt;br /&gt;&lt;br /&gt;If you are the owner of this site please check that MySQL is running properly and all tables are error free.&lt;br /&gt;&lt;br /&gt;&quot;;
-                if ( $check == false ) {
-                        $msg .= &quot;&lt;strong&gt;Database Tables Missing.&lt;/strong&gt;&lt;br /&gt;Database tables are missing. This means that MySQL is either not running, WPMU was not installed properly, or someone deleted {$wpdb-&gt;site}. You really &lt;em&gt;should&lt;/em&gt; look at your database now.&lt;br /&gt;&quot;;
-                } else {
-                        $msg .= '&lt;strong&gt;Could Not Find Blog!&lt;/strong&gt;&lt;br /&gt;';
-                        $msg .= &quot;Searched for &lt;em&gt;&quot; . $domain . $path . &quot;&lt;/em&gt; in &quot; . DB_NAME . &quot;::&quot; . $wpdb-&gt;blogs . &quot; table. Is that right?&lt;br /&gt;&quot;;
-                }
-                $msg .= &quot;&lt;br /&gt;\n&lt;h1&gt;What do I do now?&lt;/h1&gt;&quot;;
-                $msg .= &quot;Read the &lt;a target='_blank' href='http://codex.wordpress.org/Debugging_WPMU'&gt;bug report&lt;/a&gt; page. Some of the guidelines there may help you figure out what went wrong.&lt;br /&gt;&quot;;
-                $msg .= &quot;If you're still stuck with this message, then check that your database contains the following tables:&lt;ul&gt;
-                        &lt;li&gt; $wpdb-&gt;blogs &lt;/li&gt;
-                        &lt;li&gt; $wpdb-&gt;users &lt;/li&gt;
-                        &lt;li&gt; $wpdb-&gt;usermeta &lt;/li&gt;
-                        &lt;li&gt; $wpdb-&gt;site &lt;/li&gt;
-                        &lt;li&gt; $wpdb-&gt;sitemeta &lt;/li&gt;
-                        &lt;li&gt; $wpdb-&gt;sitecategories &lt;/li&gt;
-                        &lt;/ul&gt;&quot;;
-                $msg .= &quot;If you suspect a problem please report it to the support forums but you must include the information asked for in the &lt;a href='http://codex.wordpress.org/Debugging_WPMU'&gt;WPMU bug reporting guidelines&lt;/a&gt;!&lt;br /&gt;&lt;br /&gt;&quot;;
-                if ( is_file( 'release-info.txt' ) ) {
-                        $msg .= 'Your bug report must include the following text: &quot;';
-                        $info = file( 'release-info.txt' );
-                        $msg .= $info[ 4 ] . '&quot;';
-                }
</del><ins>+$wpdb-&gt;blogid = $current_blog-&gt;blog_id;
+$wpdb-&gt;siteid = $current_blog-&gt;site_id;
+$wpdb-&gt;set_prefix($table_prefix); // set up blog tables
+$table_prefix = $wpdb-&gt;get_blog_prefix();
</ins><span class="cx"> 
</span><del>-                die( &quot;&lt;h1&gt;Fatal Error&lt;/h1&gt; &quot; . $msg );
-        }
</del><ins>+// Fix empty PHP_SELF
+$PHP_SELF = $_SERVER['PHP_SELF'];
+if ( empty($PHP_SELF) || ( empty($PHP_SELF) &amp;&amp; !is_subdomain_install() &amp;&amp; $current_blog-&gt;path != '/' ) )
+        $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace(&quot;/(\?.*)?$/&quot;,'',$_SERVER[&quot;REQUEST_URI&quot;]);
+
+wp_cache_init(); // need to init cache again after blog_id is set
+if ( function_exists('wp_cache_add_global_groups') ) { // need to add these again. Yes, it's an ugly hack
+        wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss'));
+        wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+ms_default_constants( 'uploads' );
+
</ins><span class="cx"> ?&gt;
</span></span></pre></div>
<a id="trunkwpsettingsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-settings.php (12884 => 12885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-settings.php        2010-01-28 15:29:23 UTC (rev 12884)
+++ trunk/wp-settings.php        2010-01-28 16:09:52 UTC (rev 12885)
</span><span class="lines">@@ -75,7 +75,7 @@
</span><span class="cx"> 
</span><span class="cx"> // Initialize multisite if enabled.
</span><span class="cx"> if ( is_multisite() )
</span><del>-        require( ABSPATH . WPINC . '/ms-load.php' );
</del><ins>+        require( ABSPATH . WPINC . '/ms-settings.php' );
</ins><span class="cx"> 
</span><span class="cx"> // Load early WordPress files.
</span><span class="cx"> require( ABSPATH . WPINC . '/plugin.php' );
</span><span class="lines">@@ -162,7 +162,7 @@
</span><span class="cx">                 die();
</span><span class="cx">         }
</span><span class="cx">         unset($file);
</span><del>-        ms_network_cookies();
</del><ins>+        ms_default_constants( 'cookies' );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Define constants after multisite is loaded. Cookie-related constants may be overridden in ms_network_cookies().
</span></span></pre>
</div>
</div>

</body>
</html>