<!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>[13622] trunk: Allow localhost in a multisite subdirectory install.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13622">13622</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-03-09 06:14:42 +0000 (Tue, 09 Mar 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Allow localhost in a multisite subdirectory install. More network.php improvements. see <a href="http://trac.wordpress.org/ticket/12457">#12457</a> for localhost. see <a href="http://trac.wordpress.org/ticket/11816">#11816</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminnetworkphp">trunk/wp-admin/network.php</a></li>
<li><a href="#trunkwpincludesmsdefaultconstantsphp">trunk/wp-includes/ms-default-constants.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>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminnetworkphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/network.php (13621 => 13622)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/network.php        2010-03-08 22:14:11 UTC (rev 13621)
+++ trunk/wp-admin/network.php        2010-03-09 06:14:42 UTC (rev 13622)
</span><span class="lines">@@ -56,11 +56,9 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         $hostname = get_clean_basedomain();
</span><del>-        if ( 'localhost' == $hostname || preg_match( '|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|', $hostname ) ) {
</del><ins>+        if ( preg_match( '|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|', $hostname ) ) {
</ins><span class="cx">                 echo '<p><strong>' . __('You cannot install a network of sites with your server address.' ) . '</strong></p>';
</span><del>-                echo '<p>' . __('You cannot use an IP address such as <code>127.0.0.1</code> or a single-word hostname like <code>localhost</code>.' ) . '</p>';
-                if ( 'localhost' == $hostname )
-                        echo '<p>' . __('Consider using <code>localhost.localdomain</code>.') . '</p>';
</del><ins>+                echo '<p>' . __('You cannot use an IP address such as <code>127.0.0.1</code>.' ) . '</p>';
</ins><span class="cx">                 include( './admin-footer.php' );
</span><span class="cx">                 die();
</span><span class="cx">         }
</span><span class="lines">@@ -93,8 +91,8 @@
</span><span class="cx">                 <input type='hidden' name='existing_network' value='0' />
</span><span class="cx"> <?php        } ?>
</span><span class="cx">                 <input type='hidden' name='action' value='step2' />
</span><ins>+<?php        if ( 'localhost' != $hostname ) : ?>
</ins><span class="cx">                 <h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
</span><del>-        
</del><span class="cx">                 <p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories. <strong>You cannot change this later.</strong>' ); ?></p>
</span><span class="cx">                 <p><?php _e( "You will need a wildcard DNS record if you're going to use the virtual host (sub-domain) functionality." ); ?></p>
</span><span class="cx">                 <?php /* @todo: Link to an MS readme? */ ?>
</span><span class="lines">@@ -113,6 +111,8 @@
</span><span class="cx">                 </table>
</span><span class="cx">
</span><span class="cx">                 <?php
</span><ins>+                endif;
+
</ins><span class="cx">                 $is_www = ( substr( $hostname, 0, 4 ) == 'www.' );
</span><span class="cx">                 if ( $is_www ) :
</span><span class="cx">                 ?>
</span><span class="lines">@@ -131,6 +131,12 @@
</span><span class="cx">
</span><span class="cx">                 <h3><?php esc_html_e( 'Network Details' ); ?></h3>
</span><span class="cx">                 <table class="form-table">
</span><ins>+                <?php if ( 'localhost' == $hostname ) : ?>
+                        <tr>
+                                <th scope="row"><?php esc_html_e( 'Sub-directory Install' ); ?></th>
+                                <td><?php _e('Because you are using <code>localhost</code>, the sites in your WordPress network must use sub-directories. Consider using <code>localhost.localdomain</code> if you wish to use sub-domains.'); ?></td>
+                        </tr>
+                <?php endif; ?>
</ins><span class="cx">                 <?php if ( ! $is_www ) : ?>
</span><span class="cx">                         <tr>
</span><span class="cx">                                 <th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
</span><span class="lines">@@ -174,7 +180,7 @@
</span><span class="cx">                         <li><p><?php printf( __( 'Add the following to your <code>wp-config.php</code> file in <code>%s</code>:' ), ABSPATH ); ?></p>
</span><span class="cx">                                 <textarea class="code" readonly="readonly" cols="100" rows="7">
</span><span class="cx"> define( 'MULTISITE', true );
</span><del>-define( 'VHOST', '<?php echo 'yes' == stripslashes( $_POST['vhost'] ) ? 'yes' : 'no'; ?>' );
</del><ins>+define( 'VHOST', '<?php echo ( ! empty( $_POST['vhost'] ) && 'yes' == stripslashes( $_POST['vhost'] ) ) ? 'yes' : 'no'; ?>' );
</ins><span class="cx"> $base = '<?php echo $base; ?>';
</span><span class="cx"> define( 'DOMAIN_CURRENT_SITE', '<?php echo get_clean_basedomain(); ?>' );
</span><span class="cx"> define( 'PATH_CURRENT_SITE', '<?php echo $base; ?>' );
</span><span class="lines">@@ -257,8 +263,10 @@
</span><span class="cx">                 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
</span><span class="cx">                 // create network tables
</span><span class="cx">                 install_network();
</span><ins>+                $hostname = get_clean_basedomain();
+                $vhost = 'localhost' == $hostname ? false : (bool) $_POST['vhost'];
</ins><span class="cx">                 if ( !network_domain_check() || isset( $_POST['existing_network'] ) && $_POST['existing_network'] == '0' )
</span><del>-                        populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $_POST['vhost'] );
</del><ins>+                        populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $vhost );
</ins><span class="cx">                 // create wp-config.php / htaccess
</span><span class="cx">                 network_step2();
</span><span class="cx">                 break;
</span></span></pre></div>
<a id="trunkwpincludesmsdefaultconstantsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-default-constants.php (13621 => 13622)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-default-constants.php        2010-03-08 22:14:11 UTC (rev 13621)
+++ trunk/wp-includes/ms-default-constants.php        2010-03-09 06:14:42 UTC (rev 13622)
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx">         /**
</span><span class="cx">          * @since 2.0.0
</span><span class="cx">          */
</span><del>-        if ( !defined('COOKIE_DOMAIN') ) {
</del><ins>+        if ( !defined('COOKIE_DOMAIN') && 'localhost' != $current_site->cookie_domain ) {
</ins><span class="cx">                 if ( isset( $current_site->cookie_domain ) )
</span><span class="cx">                         define('COOKIE_DOMAIN', '.' . $current_site->cookie_domain);
</span><span class="cx">                 else
</span></span></pre></div>
<a id="trunkwpincludesmsloadphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-load.php (13621 => 13622)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-load.php        2010-03-08 22:14:11 UTC (rev 13621)
+++ trunk/wp-includes/ms-load.php        2010-03-09 06:14:42 UTC (rev 13622)
</span><span class="lines">@@ -182,20 +182,22 @@
</span><span class="cx"> *
</span><span class="cx"> * Used when blog does not exist. Checks for a missing $wpdb->site table as well.
</span><span class="cx"> *
</span><ins>+ * @todo update for 3.0, pare down, and i18n
+ *
</ins><span class="cx"> * @access private
</span><span class="cx"> * @since 3.0.0
</span><span class="cx"> */
</span><span class="cx"> function ms_not_installed() {
</span><span class="cx">         global $wpdb, $domain, $path;
</span><span class="cx">
</span><del>-        $msg = '<h1>' . esc_html( 'Fatal Error' ) . '</h1>';
-        $msg = '<p>' . 'If your site does not display, please contact the owner of this network.' . '</p>';
</del><ins>+        $msg = '<h1>' . 'Fatal Error' . '</h1>';
+        $msg .= '<p>' . 'If your site does not display, please contact the owner of this network.' . '</p>';
</ins><span class="cx">         $msg .= '<p>' . 'If you are the owner of this network please check that MySQL is running properly and all tables are error free.' . '</p>';
</span><span class="cx">         if ( ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) )
</span><span class="cx">                 $msg .= '<p>' . sprintf( '<strong>Database tables are missing.</strong> This means that MySQL is not running, WordPress was not installed properly, or someone deleted <code>%s</code>. You really <em>should</em> look at your database now.', $wpdb->site ) . '</p>';
</span><span class="cx">         else
</span><span class="cx">                 $msg .= '<p>' . sprintf( '<strong>Could Not Find Site!</strong> Searched for table <em>%1$s</em> in <code>%2$s</code>. Is that right?', $domain . $path, DB_NAME, $wpdb->blogs ) . '</p>';
</span><del>-        $msg .= '<h1>' . esc_html( 'What do I do now?' ) . '</h1>';
</del><ins>+        $msg .= '<h1>' . 'What do I do now?' . '</h1>';
</ins><span class="cx">         // @todo Update WPMU codex link.
</span><span class="cx">         $msg .= '<p>' . 'Read the <a target="_blank" href="http://codex.wordpress.org/Debugging_WPMU">bug report</a> page. Some of the guidelines there may help you figure out what went wrong.' . '</p>';
</span><span class="cx">         $msg .= '<p>' . "If you're still stuck with this message, then check that your database contains the following tables:" . '</p><ul>';
</span><span class="lines">@@ -204,15 +206,8 @@
</span><span class="cx">         }
</span><span class="cx">         $msg .= '</ul>';
</span><span class="cx">         // @todo Update WPMU codex link and support instructions.
</span><del>-        $msg = '<p>' . 'If you suspect a problem please report it to the support forums but you must include the information asked for in the <a target="_blank" href="http://codex.wordpress.org/Debugging_WPMU">WPMU bug reporting guidelines</a>! ' . '</p>';
</del><ins>+        $msg .= '<p>' . 'If you suspect a problem please report it to the support forums but you must include the information asked for in the <a target="_blank" href="http://codex.wordpress.org/Debugging_WPMU">WPMU bug reporting guidelines</a>! ' . '</p>';
</ins><span class="cx">
</span><del>-        // @todo This file no longer exists post-merge.
-        if ( is_file( 'release-info.txt' ) ) {
-                $msg .= '<p>' . 'Your bug report must include the following text:' . '</p>';
-                $info = file( 'release-info.txt' );
-                $msg .= $info[ 4 ] . '"';
-        }
-
</del><span class="cx">         die( $msg );
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludesmssettingsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-settings.php (13621 => 13622)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-settings.php        2010-03-08 22:14:11 UTC (rev 13621)
+++ trunk/wp-includes/ms-settings.php        2010-03-09 06:14:42 UTC (rev 13622)
</span><span class="lines">@@ -11,7 +11,7 @@
</span><span class="cx">
</span><span class="cx"> // $base sanity check.
</span><span class="cx"> if ( 'BASE' == $base )
</span><del>-        die( 'Configuration error in <code>wp-config.php<code>. <code>$base</code> is set to "BASE" when it should be the path like "/" or "/blogs/".' );
</del><ins>+        die( 'Configuration error in <code>wp-config.php</code>. <code>$base</code> is set to "BASE" when it should be the path like "/" or "/blogs/".' );
</ins><span class="cx">
</span><span class="cx"> /** Include Multisite initialization functions */
</span><span class="cx"> require( ABSPATH . WPINC . '/ms-load.php' );
</span></span></pre>
</div>
</div>
</body>
</html>