From 9cde54cbda1ef4d3dcc8a89efff47b5873bbf54c Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 11 Feb 2018 18:46:48 +0000 Subject: [PATCH] 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 --- src/wp-includes/load.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php index a29eed1002..71b3a4a3e7 100644 --- a/src/wp-includes/load.php +++ b/src/wp-includes/load.php @@ -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 ); } /**