<!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" />
<title>[28978] trunk/src: Simplify the setup-config.php UI flow and load process.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/28978">28978</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2014-07-03 19:56:37 +0000 (Thu, 03 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>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 <a href="http://core.trac.wordpress.org/ticket/28740">#28740</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminloadscriptsphp">trunk/src/wp-admin/load-scripts.php</a></li>
<li><a href="#trunksrcwpadminloadstylesphp">trunk/src/wp-admin/load-styles.php</a></li>
<li><a href="#trunksrcwpadminsetupconfigphp">trunk/src/wp-admin/setup-config.php</a></li>
<li><a href="#trunksrcwpincludesjstinymcewptinymcephp">trunk/src/wp-includes/js/tinymce/wp-tinymce.php</a></li>
<li><a href="#trunksrcwpincludeswpdbphp">trunk/src/wp-includes/wp-db.php</a></li>
<li><a href="#trunksrcwploadphp">trunk/src/wp-load.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminloadscriptsphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/load-scripts.php (28977 => 28978)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/load-scripts.php      2014-07-03 19:41:23 UTC (rev 28977)
+++ trunk/src/wp-admin/load-scripts.php 2014-07-03 19:56:37 UTC (rev 28978)
</span><span class="lines">@@ -3,7 +3,7 @@
</span><span class="cx"> /**
</span><span class="cx">  * Disable error reporting
</span><span class="cx">  *
</span><del>- * Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
</del><ins>+ * Set this to error_reporting( -1 ) for debugging
</ins><span class="cx">  */
</span><span class="cx"> error_reporting(0);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunksrcwpadminloadstylesphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/load-styles.php (28977 => 28978)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/load-styles.php       2014-07-03 19:41:23 UTC (rev 28977)
+++ trunk/src/wp-admin/load-styles.php  2014-07-03 19:56:37 UTC (rev 28978)
</span><span class="lines">@@ -3,7 +3,7 @@
</span><span class="cx"> /**
</span><span class="cx">  * Disable error reporting
</span><span class="cx">  *
</span><del>- * Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
</del><ins>+ * Set this to error_reporting( -1 ) for debugging
</ins><span class="cx">  */
</span><span class="cx"> error_reporting(0);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunksrcwpadminsetupconfigphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/setup-config.php (28977 => 28978)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/setup-config.php      2014-07-03 19:41:23 UTC (rev 28977)
+++ trunk/src/wp-admin/setup-config.php 2014-07-03 19:56:37 UTC (rev 28978)
</span><span class="lines">@@ -24,45 +24,16 @@
</span><span class="cx"> /**
</span><span class="cx">  * Disable error reporting
</span><span class="cx">  *
</span><del>- * Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
</del><ins>+ * Set this to error_reporting( -1 ) for debugging
</ins><span class="cx">  */
</span><del>-error_reporting(0);
</del><ins>+error_reporting(-1);
</ins><span class="cx"> 
</span><del>-/**#@+
- * 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);
-/**#@-*/
</del><ins>+define( 'ABSPATH', dirname( dirname( __FILE__ ) ) . '/' );
</ins><span class="cx"> 
</span><del>-require(ABSPATH . WPINC . '/load.php');
-require(ABSPATH . WPINC . '/version.php');
</del><ins>+require_once( ABSPATH . 'wp-includes/plugin.php' );
+add_action( 'plugins_loaded', 'wp_load_translations_early' );
+require( ABSPATH . 'wp-settings.php' );
</ins><span class="cx"> 
</span><del>-// 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();
-
</del><span class="cx"> // Support wp-config-sample.php one level up, for the develop repo.
</span><span class="cx"> if ( file_exists( ABSPATH . 'wp-config-sample.php' ) )
</span><span class="cx">  $config_file = file( ABSPATH . 'wp-config-sample.php' );
</span><span class="lines">@@ -120,7 +91,11 @@
</span><span class="cx">  <li><?php _e( 'Database host' ); ?></li>
</span><span class="cx">  <li><?php _e( 'Table prefix (if you want to run more than one WordPress in a single database)' ); ?></li>
</span><span class="cx"> </ol>
</span><del>-<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>
</del><ins>+<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>
</ins><span class="cx"> <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>
</span><span class="cx"> 
</span><span class="cx"> <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>
</span><span class="lines">@@ -191,29 +166,25 @@
</span><span class="cx">  define('DB_HOST', $dbhost);
</span><span class="cx">  /**#@-*/
</span><span class="cx"> 
</span><del>-       // We'll fail here if the values are no good.
</del><ins>+        // Re-construct $wpdb with these new values.
+       unset( $wpdb );
</ins><span class="cx">   require_wp_db();
</span><ins>+
+       // 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();
+
</ins><span class="cx">   if ( ! empty( $wpdb->error ) )
</span><span class="cx">          wp_die( $wpdb->error->get_error_message() . $tryagain_link );
</span><span class="cx"> 
</span><span class="cx">  // Fetch or generate keys and salts.
</span><span class="cx">  $no_api = isset( $_POST['noapi'] );
</span><span class="cx">  if ( ! $no_api ) {
</span><del>-               require_once( ABSPATH . WPINC . '/class-http.php' );
-               require_once( ABSPATH . WPINC . '/http.php' );
-               /**#@+
-                * @ignore
-                */
-               function get_bloginfo() {
-                       return wp_guess_url();
-               }
-               /**#@-*/
</del><span class="cx">           $secret_keys = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  if ( $no_api || is_wp_error( $secret_keys ) ) {
</span><span class="cx">          $secret_keys = array();
</span><del>-               require_once( ABSPATH . WPINC . '/pluggable.php' );
</del><span class="cx">           for ( $i = 0; $i < 8; $i++ ) {
</span><span class="cx">                  $secret_keys[] = wp_generate_password( 64, true, true );
</span><span class="cx">          }
</span></span></pre></div>
<a id="trunksrcwpincludesjstinymcewptinymcephp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/js/tinymce/wp-tinymce.php (28977 => 28978)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/js/tinymce/wp-tinymce.php  2014-07-03 19:41:23 UTC (rev 28977)
+++ trunk/src/wp-includes/js/tinymce/wp-tinymce.php     2014-07-03 19:56:37 UTC (rev 28978)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> /**
</span><span class="cx">  * Disable error reporting
</span><span class="cx">  *
</span><del>- * Set this to error_reporting( E_ALL ) or error_reporting( E_ALL | E_STRICT ) for debugging
</del><ins>+ * Set this to error_reporting( -1 ) for debugging
</ins><span class="cx">  */
</span><span class="cx"> error_reporting(0);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunksrcwpincludeswpdbphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/wp-db.php (28977 => 28978)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/wp-db.php  2014-07-03 19:41:23 UTC (rev 28977)
+++ trunk/src/wp-includes/wp-db.php     2014-07-03 19:56:37 UTC (rev 28978)
</span><span class="lines">@@ -604,6 +604,11 @@
</span><span class="cx">          $this->dbname = $dbname;
</span><span class="cx">          $this->dbhost = $dbhost;
</span><span class="cx"> 
</span><ins>+               // wp-config.php creation will manually connect when ready.
+               if ( defined( 'WP_SETUP_CONFIG' ) ) {
+                       return;
+               }
+
</ins><span class="cx">           $this->db_connect();
</span><span class="cx">  }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunksrcwploadphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-load.php (28977 => 28978)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-load.php    2014-07-03 19:41:23 UTC (rev 28977)
+++ trunk/src/wp-load.php       2014-07-03 19:56:37 UTC (rev 28978)
</span><span class="lines">@@ -38,13 +38,8 @@
</span><span class="cx">  // A config file doesn't exist
</span><span class="cx"> 
</span><span class="cx">  define( 'WPINC', 'wp-includes' );
</span><del>-       define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
</del><span class="cx">   require_once( ABSPATH . WPINC . '/load.php' );
</span><del>-       require_once( ABSPATH . WPINC . '/version.php' );
</del><span class="cx"> 
</span><del>-       wp_check_php_mysql_versions();
-       wp_load_translations_early();
-
</del><span class="cx">   // Standardize $_SERVER variables across setups.
</span><span class="cx">  wp_fix_server_vars();
</span><span class="cx"> 
</span><span class="lines">@@ -52,6 +47,21 @@
</span><span class="cx"> 
</span><span class="cx">  $path = wp_guess_url() . '/wp-admin/setup-config.php';
</span><span class="cx"> 
</span><ins>+       /* 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();
+
</ins><span class="cx">   // Die with an error message
</span><span class="cx">  $die  = __( "There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started." ) . '</p>';
</span><span class="cx">  $die .= '<p>' . __( "Need more help? <a href='http://codex.wordpress.org/Editing_wp-config.php'>We got it</a>." ) . '</p>';
</span></span></pre>
</div>
</div>

</body>
</html>