Simplify the setup-config.php UI flow and load process.

When no configuration file is detected, we now redirect to setup-config.php. This process now uses the WordPress bootstrap, rather than a set of fragile hacks.

fixes #28740.

Built from https://develop.svn.wordpress.org/trunk@28978


git-svn-id: http://core.svn.wordpress.org/trunk@28767 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2014-07-03 19:57:14 +00:00
parent 6623df8b1f
commit b35982cbff
6 changed files with 41 additions and 55 deletions

View File

@ -3,7 +3,7 @@
/**
* Disable error reporting
*
* Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
* Set this to error_reporting( -1 ) for debugging
*/
error_reporting(0);

View File

@ -3,7 +3,7 @@
/**
* Disable error reporting
*
* Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
* Set this to error_reporting( -1 ) for debugging
*/
error_reporting(0);

View File

@ -24,44 +24,15 @@ define('WP_SETUP_CONFIG', true);
/**
* Disable error reporting
*
* Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
* Set this to error_reporting( -1 ) for debugging
*/
error_reporting(0);
error_reporting(-1);
/**#@+
* These three defines are required to allow us to use require_wp_db() to load
* the database class while being wp-content/db.php aware.
* @ignore
*/
define('ABSPATH', dirname(dirname(__FILE__)).'/');
define('WPINC', 'wp-includes');
define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
define('WP_DEBUG', false);
/**#@-*/
define( 'ABSPATH', dirname( dirname( __FILE__ ) ) . '/' );
require(ABSPATH . WPINC . '/load.php');
require(ABSPATH . WPINC . '/version.php');
// Check for the required PHP version and for the MySQL extension or a database drop-in.
wp_check_php_mysql_versions();
require_once(ABSPATH . WPINC . '/functions.php');
// Also loads plugin.php, l10n.php, pomo/mo.php (all required by setup-config.php)
wp_load_translations_early();
// Turn register_globals off.
wp_unregister_GLOBALS();
// Standardize $_SERVER variables across setups.
wp_fix_server_vars();
require_once(ABSPATH . WPINC . '/compat.php');
require_once(ABSPATH . WPINC . '/class-wp-error.php');
require_once(ABSPATH . WPINC . '/formatting.php');
// Add magic quotes and set up $_REQUEST ( $_GET + $_POST )
wp_magic_quotes();
require_once( ABSPATH . 'wp-includes/plugin.php' );
add_action( 'plugins_loaded', 'wp_load_translations_early' );
require( ABSPATH . 'wp-settings.php' );
// Support wp-config-sample.php one level up, for the develop repo.
if ( file_exists( ABSPATH . 'wp-config-sample.php' ) )
@ -120,7 +91,11 @@ switch($step) {
<li><?php _e( 'Database host' ); ?></li>
<li><?php _e( 'Table prefix (if you want to run more than one WordPress in a single database)' ); ?></li>
</ol>
<p><strong><?php _e( "If for any reason this automatic file creation doesn&#8217;t work, don&#8217;t worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>." ); ?></strong></p>
<p>
<?php _e( 'We&#8217;re going to use this information to create a <code>wp-config.php</code> file.' ); ?>
<strong><?php _e( "If for any reason this automatic file creation doesn&#8217;t work, don&#8217;t worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>." ); ?></strong>
<?php _e( "Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>." ); ?>
</p>
<p><?php _e( "In all likelihood, these items were supplied to you by your Web Host. If you do not have this information, then you will need to contact them before you can continue. If you&#8217;re all ready&hellip;" ); ?></p>
<p class="step"><a href="setup-config.php?step=1<?php if ( isset( $_GET['noapi'] ) ) echo '&amp;noapi'; ?>" class="button button-large"><?php _e( 'Let&#8217;s go!' ); ?></a></p>
@ -191,29 +166,25 @@ switch($step) {
define('DB_HOST', $dbhost);
/**#@-*/
// We'll fail here if the values are no good.
// Re-construct $wpdb with these new values.
unset( $wpdb );
require_wp_db();
// The wpdb constructor bails when WP_SETUP_CONFIG is set, so we must
// fire this manually. We'll fail here if the values are no good.
$wpdb->db_connect();
if ( ! empty( $wpdb->error ) )
wp_die( $wpdb->error->get_error_message() . $tryagain_link );
// Fetch or generate keys and salts.
$no_api = isset( $_POST['noapi'] );
if ( ! $no_api ) {
require_once( ABSPATH . WPINC . '/class-http.php' );
require_once( ABSPATH . WPINC . '/http.php' );
/**#@+
* @ignore
*/
function get_bloginfo() {
return wp_guess_url();
}
/**#@-*/
$secret_keys = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
}
if ( $no_api || is_wp_error( $secret_keys ) ) {
$secret_keys = array();
require_once( ABSPATH . WPINC . '/pluggable.php' );
for ( $i = 0; $i < 8; $i++ ) {
$secret_keys[] = wp_generate_password( 64, true, true );
}

View File

@ -2,7 +2,7 @@
/**
* Disable error reporting
*
* Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
* Set this to error_reporting( -1 ) for debugging
*/
error_reporting(0);

View File

@ -604,6 +604,11 @@ class wpdb {
$this->dbname = $dbname;
$this->dbhost = $dbhost;
// wp-config.php creation will manually connect when ready.
if ( defined( 'WP_SETUP_CONFIG' ) ) {
return;
}
$this->db_connect();
}

View File

@ -38,12 +38,7 @@ if ( file_exists( ABSPATH . 'wp-config.php') ) {
// A config file doesn't exist
define( 'WPINC', 'wp-includes' );
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
require_once( ABSPATH . WPINC . '/load.php' );
require_once( ABSPATH . WPINC . '/version.php' );
wp_check_php_mysql_versions();
wp_load_translations_early();
// Standardize $_SERVER variables across setups.
wp_fix_server_vars();
@ -52,6 +47,21 @@ if ( file_exists( ABSPATH . 'wp-config.php') ) {
$path = wp_guess_url() . '/wp-admin/setup-config.php';
/* We're going to redirect to setup-config.php. While this shouldn't result
* in an infinite loop, that's a silly thing to assume, don't you think? If
* we're traveling in circles, our last-ditch effort is "Need more help?"
*/
if ( false === strpos( $_SERVER['REQUEST_URI'], 'setup-config' ) ) {
header( 'Location: ' . $path );
exit;
}
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
require_once( ABSPATH . WPINC . '/version.php' );
wp_check_php_mysql_versions();
wp_load_translations_early();
// Die with an error message
$die = __( "There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started." ) . '</p>';
$die .= '<p>' . __( "Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>." ) . '</p>';