<!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>[12688] trunk: multi-site startup, See #11644</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12688">12688</a></dd>
<dt>Author</dt> <dd>wpmuguru</dd>
<dt>Date</dt> <dd>2010-01-10 18:10:51 +0000 (Sun, 10 Jan 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>multi-site startup, See <a href="http://trac.wordpress.org/ticket/11644">#11644</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpsettingsphp">trunk/wp-settings.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkwpincludesmsloadphp">trunk/wp-includes/ms-load.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesmsloadphp"></a>
<div class="addfile"><h4>Added: trunk/wp-includes/ms-load.php (0 => 12688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-load.php         (rev 0)
+++ trunk/wp-includes/ms-load.php        2010-01-10 18:10:51 UTC (rev 12688)
</span><span class="lines">@@ -0,0 +1,164 @@
</span><ins>+<?php
+/**
+ * Used to setup and fix common variables and include
+ * the WordPress procedural and class library.
+ *
+ * You should not have to change this file and allows
+ * for some configuration in wp-config.php.
+ *
+ * @since 3.0
+ *
+ * @package WordPress
+ */
+if( defined( 'SUNRISE' ) )
+        include_once( WP_CONTENT_DIR . '/sunrise.php' );
+
+ require (ABSPATH . WPINC . '/ms-settings.php');
+$wpdb->blogid = $current_blog->blog_id;
+$wpdb->siteid = $current_blog->site_id;
+$wpdb->set_prefix($table_prefix); // set up blog tables
+$table_prefix = $table_prefix . $blog_id . '_';
+
+// Fix empty PHP_SELF
+$PHP_SELF = $_SERVER['PHP_SELF'];
+if ( empty($PHP_SELF) || ( empty($PHP_SELF) && constant( 'VHOST' ) == 'no' && $current_blog->path != '/' ) )
+        $_SERVER['PHP_SELF'] = $PHP_SELF = preg_replace("/(\?.*)?$/",'',$_SERVER["REQUEST_URI"]);
+
+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' ));
+}
+
+if( !defined( "UPLOADBLOGSDIR" ) )
+        define( "UPLOADBLOGSDIR", 'wp-content/blogs.dir' );
+
+if( !defined( "UPLOADS" ) )
+        define( "UPLOADS", UPLOADBLOGSDIR . "/{$wpdb->blogid}/files/" );
+
+if( !defined( "BLOGUPLOADDIR" ) )
+        define( "BLOGUPLOADDIR", WP_CONTENT_DIR . "/blogs.dir/{$wpdb->blogid}/files/" );
+
+function ms_network_settings() {
+ global $wpdb, $current_site, $cookiehash;
+
+ if( !isset($current_site->site_name) )
+ $current_site->site_name = get_site_option('site_name');
+
+ if( $current_site->site_name == false )
+ $current_site->site_name = ucfirst( $current_site->domain );
+
+ if ( ! defined('WP_INSTALLING') ) {
+ // Used to guarantee unique hash cookies
+ if ( !isset($cookiehash) )
+ $cookiehash = '';
+
+ /**
+ * Used to guarantee unique hash cookies
+ * @since 1.5
+ */
+ if ( !defined('COOKIEHASH') )
+ define( 'COOKIEHASH', $cookiehash );
+ }
+
+ $wpdb->hide_errors();
+}
+
+function ms_network_plugins() {
+ $wpmu_sitewide_plugins = (array) maybe_unserialize( get_site_option( 'wpmu_sitewide_plugins' ) );
+ foreach( $wpmu_sitewide_plugins as $plugin_file => $activation_time ) {
+ if ( !$plugin_file )
+ continue;
+
+ if ( !file_exists( WP_PLUGIN_DIR . '/' . $plugin_file ) ) {
+ $deleted_sitewide_plugins[] = $plugin_file;
+ } else {
+ include_once( WP_PLUGIN_DIR . '/' . $plugin_file );
+ }
+ }
+
+ if ( isset( $deleted_sitewide_plugins ) ) {
+ $active_sitewide_plugins = maybe_unserialize( get_site_option( 'active_sitewide_plugins' ) );
+
+ /* Remove any deleted plugins from the wpmu_sitewide_plugins array */
+ foreach( $deleted_sitewide_plugins as $plugin_file ) {
+ unset( $wpmu_sitewide_plugins[$plugin_file] );
+ unset( $active_sitewide_plugins[$plugin_file] );
+ }
+
+ update_site_option( 'wpmu_sitewide_plugins', $wpmu_sitewide_plugins );
+ update_site_option( 'active_sitewide_plugins', $wpmu_sitewide_plugins );
+ }
+
+}
+
+function ms_site_check() {
+ global $wpdb, $current_blog;
+
+ $wpdb->show_errors();
+
+ if ( '1' == $current_blog->deleted ) {
+ if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) ) {
+ require_once( WP_CONTENT_DIR . '/blog-deleted.php' );
+ die();
+ } else {
+ header('HTTP/1.1 410 Gone');
+ graceful_fail(__('This user has elected to delete their account and the content is no longer available.'));
+ }
+ }
+
+ if ( '2' == $current_blog->deleted ) {
+ if ( file_exists( WP_CONTENT_DIR . '/blog-inactive.php' ) ) {
+ require_once( WP_CONTENT_DIR . '/blog-inactive.php' );
+ die();
+ } else {
+ graceful_fail( sprintf( __( 'This blog has not been activated yet. If you are having problems activating your blog, please contact <a href="mailto:%1$s">%1$s</a>.' ), str_replace( '@', ' AT ', get_site_option( 'admin_email', "support@{$current_site->domain}" ) ) ) );
+ }
+ }
+
+ if( $current_blog->archived == '1' || $current_blog->spam == '1' ) {
+ if ( file_exists( WP_CONTENT_DIR . '/blog-suspended.php' ) ) {
+ require_once( WP_CONTENT_DIR . '/blog-suspended.php' );
+ die();
+ } else {
+ header('HTTP/1.1 410 Gone');
+ graceful_fail(__('This blog has been archived or suspended.'));
+ }
+ }
+}
+
+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->path );
+
+ /**
+ * It is possible to define this in wp-config.php
+ * @since 1.5.0
+ */
+ if ( !defined('SITECOOKIEPATH') )
+ define('SITECOOKIEPATH', $current_site->path );
+
+ /**
+ * 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 );
+ } else {
+ define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
+ }
+ }
+ /**
+ * It is possible to define this in wp-config.php
+ * @since 2.0.0
+ */
+ if ( !defined('COOKIE_DOMAIN') )
+ define('COOKIE_DOMAIN', '.' . $current_site->domain);
+}
+?>
</ins><span class="cx">Property changes on: trunk/wp-includes/ms-load.php
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: svn:eol-style
</span><span class="cx"> + native
</span></span></pre></div>
<a id="trunkwpsettingsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-settings.php (12687 => 12688)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-settings.php        2010-01-10 15:50:17 UTC (rev 12687)
+++ trunk/wp-settings.php        2010-01-10 18:10:51 UTC (rev 12688)
</span><span class="lines">@@ -9,9 +9,29 @@
</span><span class="cx"> * @package WordPress
</span><span class="cx"> */
</span><span class="cx">
</span><del>-if ( !defined('WP_MEMORY_LIMIT') )
-        define('WP_MEMORY_LIMIT', '32M');
</del><span class="cx">
</span><ins>+/**
+ * Whether Multisite support is enabled
+ *
+ * @since 3.0
+ *
+ * @return bool True if multisite is enabled, false otherwise.
+ */
+function is_multisite() {
+        if ( ( defined('MULTISITE') && MULTISITE ) || defined('VHOST') || defined('SUNRISE') )
+                return true;
+
+        return false;
+}
+
+if ( !defined('WP_MEMORY_LIMIT') ) {
+ if( is_multisite() ) {
+         define('WP_MEMORY_LIMIT', '64M');
+ } else {
+         define('WP_MEMORY_LIMIT', '32M');
+ }
+}
+
</ins><span class="cx"> if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
</span><span class="cx">         @ini_set('memory_limit', WP_MEMORY_LIMIT);
</span><span class="cx">
</span><span class="lines">@@ -325,20 +345,6 @@
</span><span class="cx">         return false;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-/**
- * Whether Multisite support is enabled
- *
- * @since 3.0
- *
- * @return bool True if multisite is enabled, false otherwise.
- */
-function is_multisite() {
-        if ( ( defined('MULTISITE') && MULTISITE ) || defined('VHOST') )
-                return true;
-
-        return false;
-}
-
</del><span class="cx"> if ( file_exists(WP_CONTENT_DIR . '/object-cache.php') ) {
</span><span class="cx">         require_once (WP_CONTENT_DIR . '/object-cache.php');
</span><span class="cx">         $_wp_using_ext_object_cache = true;
</span><span class="lines">@@ -349,16 +355,32 @@
</span><span class="cx">
</span><span class="cx"> wp_cache_init();
</span><span class="cx"> if ( function_exists('wp_cache_add_global_groups') ) {
</span><del>-        wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta', 'site-transient'));
</del><ins>+ if( is_multisite() ) {
+ wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss'));
+ } else {
+         wp_cache_add_global_groups(array ('users', 'userlogins', 'usermeta', 'site-transient'));
+ }
</ins><span class="cx">         wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+if( is_multisite() ) {
+ require (ABSPATH . WPINC . '/ms-load.php');
+}
+
</ins><span class="cx"> require (ABSPATH . WPINC . '/plugin.php');
</span><span class="cx"> require (ABSPATH . WPINC . '/default-filters.php');
</span><span class="cx"> include_once(ABSPATH . WPINC . '/pomo/mo.php');
</span><ins>+
+if( is_multisite() && defined( "SHORTINIT" ) && SHORTINIT ) // stop most of WP being loaded, we just want the basics
+        return false;
+
</ins><span class="cx"> require_once (ABSPATH . WPINC . '/l10n.php');
</span><span class="cx">
</span><del>-if ( !is_blog_installed() && (strpos($_SERVER['PHP_SELF'], 'install.php') === false && !defined('WP_INSTALLING')) ) {
</del><ins>+if( is_multisite() ) {
+ if ( !is_blog_installed() && !defined('WP_INSTALLING') ) {
+ die( __( 'The blog you have requested is not installed properly. Please contact the system administrator.' ) ); // have to die here ~ Mark
+ }
+} elseif ( !is_blog_installed() && (strpos($_SERVER['PHP_SELF'], 'install.php') === false && !defined('WP_INSTALLING')) ) {
</ins><span class="cx">         if ( defined('WP_SITEURL') )
</span><span class="cx">                 $link = WP_SITEURL . '/wp-admin/install.php';
</span><span class="cx">         elseif (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false)
</span><span class="lines">@@ -437,6 +459,8 @@
</span><span class="cx"> if ( !defined('PLUGINDIR') )
</span><span class="cx">         define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH. For back compat.
</span><span class="cx">
</span><ins>+if( is_multisite() )
+ ms_network_settings();
</ins><span class="cx"> /**
</span><span class="cx"> * Allows for the mu-plugins directory to be moved from the default location.
</span><span class="cx"> *
</span><span class="lines">@@ -463,20 +487,40 @@
</span><span class="cx">
</span><span class="cx"> if ( is_dir( WPMU_PLUGIN_DIR ) ) {
</span><span class="cx">         if ( $dh = opendir( WPMU_PLUGIN_DIR ) ) {
</span><del>-                while ( ( $plugin = readdir( $dh ) ) !== false ) {
-                        if ( substr( $plugin, -4 ) == '.php' ) {
-                                include_once( WPMU_PLUGIN_DIR . '/' . $plugin );
-                        }
-                }
</del><ins>+                $mu_plugins = array ();
+                while ( ( $plugin = readdir( $dh ) ) !== false )
+                        if ( substr( $plugin, -4 ) == '.php' )
+                                $mu_plugins[] = $plugin;
+                closedir( $dh );
+ if( is_multisite() )
+                 sort( $mu_plugins );
+                foreach( $mu_plugins as $mu_plugin )
+                        include_once( WPMU_PLUGIN_DIR . '/' . $mu_plugin );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><ins>+/**
+ * Used to load network wide plugins
+ * @since 3.0
+ */
+if( is_multisite() )
+ ms_network_plugins();
+
</ins><span class="cx"> do_action('muplugins_loaded');
</span><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Used to check site status
+ * @since 3.0
+ */
+if( is_multisite() ) {
+ ms_site_check();
+ ms_network_cookies();
+}
+/**
</ins><span class="cx"> * Used to guarantee unique hash cookies
</span><span class="cx"> * @since 1.5
</span><span class="cx"> */
</span><del>-define('COOKIEHASH', md5(get_option('siteurl')));
</del><ins>+if( !defined('COOKIEHASH') )
+ define('COOKIEHASH', md5(get_option('siteurl')));
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Should be exactly the same as the default value of SECRET_KEY in wp-config-sample.php
</span></span></pre>
</div>
</div>
</body>
</html>