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.

git-svn-id: https://develop.svn.wordpress.org/trunk@42701 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2018-02-11 18:46:48 +00:00
parent ff8e7c03d2
commit 9cde54cbda
1 changed files with 6 additions and 1 deletions

View File

@ -418,7 +418,12 @@ function require_wp_db() {
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 );
}
/**