diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index 0f8779e305..ce0a7532ae 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -619,25 +619,29 @@ function populate_roles_300() { * @since 3.0 * * @param int $network_id id of network to populate + * @return bool|WP_Error True on success, or WP_Error on warning (with the install otherwise successful, + * so the error code must be checked) or failure. */ function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false ) { global $wpdb, $current_site, $wp_db_version, $wp_rewrite; - $msg = ''; - //@todo: turn these checks into returned messages - if ( $domain == '' ) - die( 'You must provide a domain name!' ); - if ( $site_name == '' ) - die( 'You must provide a site name!' ); + $errors = new WP_Error(); + if ( '' == $domain ) + $errors->add( 'empty_domain', __( 'You must provide a domain name.' ) ); + if ( '' == $site_name ) + $errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) ); // check for network collision - $existing_network = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ); - if ( $existing_network == $network_id ) - die( 'That network already exists!' ); + if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) ) + $errors->add( 'siteid_exists', __( 'The network already exists.' ) ); $site_user = get_user_by_email( $email ); - if ( !$site_user ) - die( 'You must provide an email address!' ); + if ( ! is_email( $email ) ) + $errors->add( 'invalid_email', __( 'You must provide a valid e-mail address.' ) ); + + if ( $errors->get_error_code() ) + return $errors; + // set up site tables $template = get_option( 'template' ); $stylesheet = get_option( 'stylesheet' ); @@ -742,26 +746,27 @@ Thanks! if ( $subdomain_install ) { $vhost_ok = false; + $errstr = ''; $hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname! $page = wp_remote_get( 'http://' . $hostname, array( 'timeout' => 5, 'httpversion' => '1.1' ) ); - if ( is_wp_error( $page ) ) { - foreach ( $page->get_error_messages() as $err ) { - $errstr = $err; - } - } elseif( $page[ 'response' ][ 'code' ] == 200 ) { + if ( is_wp_error( $page ) ) + $errstr = $page->get_error_message(); + elseif ( 200 == $page['response']['code'] ) $vhost_ok = true; - } + if ( ! $vhost_ok ) { - // @todo Update this to reflect the merge. Also: Multisite readme file, or remove the
tags. - $msg = '' . esc_html__( 'Warning! Wildcard DNS may not be configured correctly!' ) . '
'; - $msg .= '' . __( 'To use the subdomain feature of WordPress MU you must have a wildcard entry in your dns. The installer attempted to contact a random hostname ($hostname) on your domain but failed. It returned this error message:' ) . '
'; - $msg .= '
'; - $msg .= '
' . $errstr . '' . __( 'From the README.txt:' ) . '
'; - $msg .= ''; - $msg .= '' . __( "If you want to host blogs of the form http://blog.domain.tld/ where domain.tld is the domain name of your machine then you must add a wildcard record to your DNS records. This usually means adding a '*' hostname record pointing at your webserver in your DNS configuration tool. Matt has a more detailed explanation on his blog. If you still have problems, these forum messages may help." ) . '
' . __( 'You can still use your site but any subdomain you create may not be accessible. This check is not foolproof so ignore if you know your dns is correct.' ) . '
'; + $msg = '' . __( 'Warning! Wildcard DNS may not be configured correctly!' ) . '
'; + $msg .= '' . sprintf( __( 'To use a subdomain configuration, you must have a wildcard entry in your DNS. The installer attempted to contact a random hostname (
'; + $msg .= '%1$s
) on your domain.' ), $hostname ); + if ( ! empty ( $errstr ) ) + $msg .= ' ' . sprintf( __( 'This resulted in an error message: %s' ), $errstr ); + $msg .= '' . __( 'If you want to host sites in the form of
'; + $msg .= 'http://site1.example.com
then you must add a wildcard record to your DNS records. This usually means adding a*
hostname record pointing at your web server in your DNS configuration tool.' ) . '' . __( 'You can still use your site but any subdomain you create may not be accessible. If you know your DNS is correct, ignore this message.' ) . '
'; + return new WP_Error( 'no_wildcard_dns', $msg ); } } - return $msg; + + return true; } ?> diff --git a/wp-admin/network.php b/wp-admin/network.php index 9b45a908f2..d305e2953d 100644 --- a/wp-admin/network.php +++ b/wp-admin/network.php @@ -62,7 +62,7 @@ include( './admin-header.php' ); -