Database: In require_wp_db(), check if database constants are defined before using them.

Otherwise, `wp-admin/setup-config.php` triggers an undefined constant warning in PHP 7.2.

Props mariusvw, jryancard for initial patch.
Fixes #35560.
Built from https://develop.svn.wordpress.org/trunk@42701


git-svn-id: http://core.svn.wordpress.org/trunk@42529 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2018-02-11 18:47:30 +00:00
parent b2411e9e3f
commit c2e74ab915
2 changed files with 7 additions and 2 deletions

View File

@ -418,7 +418,12 @@ function require_wp_db() {
return; return;
} }
$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST ); $dbuser = defined( 'DB_USER' ) ? DB_USER : '';
$dbpassword = defined( 'DB_PASSWORD' ) ? DB_PASSWORD : '';
$dbname = defined( 'DB_NAME' ) ? DB_NAME : '';
$dbhost = defined( 'DB_HOST' ) ? DB_HOST : '';
$wpdb = new wpdb( $dbuser, $dbpassword, $dbname, $dbhost );
} }
/** /**

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.0-alpha-42700'; $wp_version = '5.0-alpha-42701';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.