Setup: Allow for wp-config-sample.php to be formatted according to coding standards.

When the setup process reads `wp-config-sample.php`, it assumes that there are no spaces inside the brackes of the `define()`s. Unfortunately, this doesn't match our coding standards, so will no longer work correctly once we start enforcing them.

This also improves coding standards of the generated `wp-config.php` file.

See #41057.



git-svn-id: https://develop.svn.wordpress.org/trunk@42218 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast 2017-11-23 05:23:01 +00:00
parent f797c252d9
commit da9953aa47

View File

@ -332,7 +332,7 @@ switch($step) {
continue; continue;
} }
if ( ! preg_match( '/^define\(\'([A-Z_]+)\',([ ]+)/', $line, $match ) ) if ( ! preg_match( '/^define\(\s*\'([A-Z_]+)\',([ ]+)/', $line, $match ) )
continue; continue;
$constant = $match[1]; $constant = $match[1];
@ -343,11 +343,11 @@ switch($step) {
case 'DB_USER' : case 'DB_USER' :
case 'DB_PASSWORD' : case 'DB_PASSWORD' :
case 'DB_HOST' : case 'DB_HOST' :
$config_file[ $line_num ] = "define('" . $constant . "'," . $padding . "'" . addcslashes( constant( $constant ), "\\'" ) . "');\r\n"; $config_file[ $line_num ] = "define( '" . $constant . "'," . $padding . "'" . addcslashes( constant( $constant ), "\\'" ) . "' );\r\n";
break; break;
case 'DB_CHARSET' : case 'DB_CHARSET' :
if ( 'utf8mb4' === $wpdb->charset || ( ! $wpdb->charset && $wpdb->has_cap( 'utf8mb4' ) ) ) { if ( 'utf8mb4' === $wpdb->charset || ( ! $wpdb->charset && $wpdb->has_cap( 'utf8mb4' ) ) ) {
$config_file[ $line_num ] = "define('" . $constant . "'," . $padding . "'utf8mb4');\r\n"; $config_file[ $line_num ] = "define( '" . $constant . "'," . $padding . "'utf8mb4' );\r\n";
} }
break; break;
case 'AUTH_KEY' : case 'AUTH_KEY' :
@ -358,7 +358,7 @@ switch($step) {
case 'SECURE_AUTH_SALT' : case 'SECURE_AUTH_SALT' :
case 'LOGGED_IN_SALT' : case 'LOGGED_IN_SALT' :
case 'NONCE_SALT' : case 'NONCE_SALT' :
$config_file[ $line_num ] = "define('" . $constant . "'," . $padding . "'" . $secret_keys[$key++] . "');\r\n"; $config_file[ $line_num ] = "define( '" . $constant . "'," . $padding . "'" . $secret_keys[$key++] . "' );\r\n";
break; break;
} }
} }