Allow localhost in a multisite subdirectory install. More network.php improvements. see #12457 for localhost. see #11816

git-svn-id: http://svn.automattic.com/wordpress/trunk@13622 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-03-09 06:14:42 +00:00
parent af1e54596c
commit 5be468ea5f
4 changed files with 23 additions and 20 deletions

View File

@ -56,11 +56,9 @@ function network_step1() {
} }
$hostname = get_clean_basedomain(); $hostname = get_clean_basedomain();
if ( 'localhost' == $hostname || preg_match( '|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|', $hostname ) ) { if ( preg_match( '|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|', $hostname ) ) {
echo '<p><strong>' . __('You cannot install a network of sites with your server address.' ) . '</strong></p>'; echo '<p><strong>' . __('You cannot install a network of sites with your server address.' ) . '</strong></p>';
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>'; echo '<p>' . __('You cannot use an IP address such as <code>127.0.0.1</code>.' ) . '</p>';
if ( 'localhost' == $hostname )
echo '<p>' . __('Consider using <code>localhost.localdomain</code>.') . '</p>';
include( './admin-footer.php' ); include( './admin-footer.php' );
die(); die();
} }
@ -93,8 +91,8 @@ function network_step1() {
<input type='hidden' name='existing_network' value='0' /> <input type='hidden' name='existing_network' value='0' />
<?php } ?> <?php } ?>
<input type='hidden' name='action' value='step2' /> <input type='hidden' name='action' value='step2' />
<?php if ( 'localhost' != $hostname ) : ?>
<h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3> <h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
<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> <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>
<p><?php _e( "You will need a wildcard DNS record if you're going to use the virtual host (sub-domain) functionality." ); ?></p> <p><?php _e( "You will need a wildcard DNS record if you're going to use the virtual host (sub-domain) functionality." ); ?></p>
<?php /* @todo: Link to an MS readme? */ ?> <?php /* @todo: Link to an MS readme? */ ?>
@ -113,6 +111,8 @@ function network_step1() {
</table> </table>
<?php <?php
endif;
$is_www = ( substr( $hostname, 0, 4 ) == 'www.' ); $is_www = ( substr( $hostname, 0, 4 ) == 'www.' );
if ( $is_www ) : if ( $is_www ) :
?> ?>
@ -131,6 +131,12 @@ function network_step1() {
<h3><?php esc_html_e( 'Network Details' ); ?></h3> <h3><?php esc_html_e( 'Network Details' ); ?></h3>
<table class="form-table"> <table class="form-table">
<?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; ?>
<?php if ( ! $is_www ) : ?> <?php if ( ! $is_www ) : ?>
<tr> <tr>
<th scope='row'><?php esc_html_e( 'Server Address' ); ?></th> <th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
@ -174,7 +180,7 @@ function network_step2() {
<li><p><?php printf( __( 'Add the following to your <code>wp-config.php</code> file in <code>%s</code>:' ), ABSPATH ); ?></p> <li><p><?php printf( __( 'Add the following to your <code>wp-config.php</code> file in <code>%s</code>:' ), ABSPATH ); ?></p>
<textarea class="code" readonly="readonly" cols="100" rows="7"> <textarea class="code" readonly="readonly" cols="100" rows="7">
define( 'MULTISITE', true ); define( 'MULTISITE', true );
define( 'VHOST', '<?php echo 'yes' == stripslashes( $_POST['vhost'] ) ? 'yes' : 'no'; ?>' ); define( 'VHOST', '<?php echo ( ! empty( $_POST['vhost'] ) && 'yes' == stripslashes( $_POST['vhost'] ) ) ? 'yes' : 'no'; ?>' );
$base = '<?php echo $base; ?>'; $base = '<?php echo $base; ?>';
define( 'DOMAIN_CURRENT_SITE', '<?php echo get_clean_basedomain(); ?>' ); define( 'DOMAIN_CURRENT_SITE', '<?php echo get_clean_basedomain(); ?>' );
define( 'PATH_CURRENT_SITE', '<?php echo $base; ?>' ); define( 'PATH_CURRENT_SITE', '<?php echo $base; ?>' );
@ -257,8 +263,10 @@ switch ( $action ) {
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
// create network tables // create network tables
install_network(); install_network();
$hostname = get_clean_basedomain();
$vhost = 'localhost' == $hostname ? false : (bool) $_POST['vhost'];
if ( !network_domain_check() || isset( $_POST['existing_network'] ) && $_POST['existing_network'] == '0' ) if ( !network_domain_check() || isset( $_POST['existing_network'] ) && $_POST['existing_network'] == '0' )
populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $_POST['vhost'] ); populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $vhost );
// create wp-config.php / htaccess // create wp-config.php / htaccess
network_step2(); network_step2();
break; break;

View File

@ -61,7 +61,7 @@ function ms_cookie_constants( ) {
/** /**
* @since 2.0.0 * @since 2.0.0
*/ */
if ( !defined('COOKIE_DOMAIN') ) { if ( !defined('COOKIE_DOMAIN') && 'localhost' != $current_site->cookie_domain ) {
if ( isset( $current_site->cookie_domain ) ) if ( isset( $current_site->cookie_domain ) )
define('COOKIE_DOMAIN', '.' . $current_site->cookie_domain); define('COOKIE_DOMAIN', '.' . $current_site->cookie_domain);
else else

View File

@ -182,20 +182,22 @@ function wpmu_current_site() {
* *
* Used when blog does not exist. Checks for a missing $wpdb->site table as well. * Used when blog does not exist. Checks for a missing $wpdb->site table as well.
* *
* @todo update for 3.0, pare down, and i18n
*
* @access private * @access private
* @since 3.0.0 * @since 3.0.0
*/ */
function ms_not_installed() { function ms_not_installed() {
global $wpdb, $domain, $path; global $wpdb, $domain, $path;
$msg = '<h1>' . esc_html( 'Fatal Error' ) . '</h1>'; $msg = '<h1>' . 'Fatal Error' . '</h1>';
$msg = '<p>' . 'If your site does not display, please contact the owner of this network.' . '</p>'; $msg .= '<p>' . 'If your site does not display, please contact the owner of this network.' . '</p>';
$msg .= '<p>' . 'If you are the owner of this network please check that MySQL is running properly and all tables are error free.' . '</p>'; $msg .= '<p>' . 'If you are the owner of this network please check that MySQL is running properly and all tables are error free.' . '</p>';
if ( ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) ) if ( ! $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) )
$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>'; $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>';
else else
$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>'; $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>';
$msg .= '<h1>' . esc_html( 'What do I do now?' ) . '</h1>'; $msg .= '<h1>' . 'What do I do now?' . '</h1>';
// @todo Update WPMU codex link. // @todo Update WPMU codex link.
$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>'; $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>';
$msg .= '<p>' . "If you're still stuck with this message, then check that your database contains the following tables:" . '</p><ul>'; $msg .= '<p>' . "If you're still stuck with this message, then check that your database contains the following tables:" . '</p><ul>';
@ -204,14 +206,7 @@ function ms_not_installed() {
} }
$msg .= '</ul>'; $msg .= '</ul>';
// @todo Update WPMU codex link and support instructions. // @todo Update WPMU codex link and support instructions.
$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>'; $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>';
// @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 ] . '"';
}
die( $msg ); die( $msg );
} }

View File

@ -11,7 +11,7 @@
// $base sanity check. // $base sanity check.
if ( 'BASE' == $base ) if ( 'BASE' == $base )
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/".' ); 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/".' );
/** Include Multisite initialization functions */ /** Include Multisite initialization functions */
require( ABSPATH . WPINC . '/ms-load.php' ); require( ABSPATH . WPINC . '/ms-load.php' );