[wp-trac] [WordPress Trac] #35560: Use of undefined constant DB_USER - assumed 'DB_USER'
WordPress Trac
noreply at wordpress.org
Thu Jan 21 14:12:42 UTC 2016
#35560: Use of undefined constant DB_USER - assumed 'DB_USER'
--------------------------+-----------------------------
Reporter: mariusvw | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Database | Version: 4.4.1
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
At my work we work in strict mode where every error needs to be solved.
Even undefined errors will fail the test platform.
In wp-includes/load.php at line 369 it is assumed that DB_USER,
DB_PASSWORD, DB_NAME and DB_HOST are defined as constants.
When you don't have a config yet this is not the case.
The solution would be muting the error or defining the constants as null.
# Solution 1, prepend above the "new wpdb()":
if (!defined('DB_USER')) {
define('DB_USER', null);
}
if (!defined('DB_PASSWORD')) {
define('DB_PASSWORD', null);
}
if (!defined('DB_NAME')) {
define('DB_NAME', null);
}
if (!defined('DB_HOST')) {
define('DB_HOST', null);
}
# Solution 2, modify the "new wpdb()" line:
$wpdb = new wpdb( @DB_USER, @DB_PASSWORD, @DB_NAME, @DB_HOST );
Where I would prefer to use solution 1.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35560>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list