Retrieving an incorrect constants value
-
There is an issue with the section in
trp-ajax.phpthat retrieves database constants fromwp-config.php, which may sometimes produce incorrect results.define()statements commented out with#become active.
- It does not handle definitions expecting variable expansion, such as
define(“DB_HOST”, “db.{$_SERVER[‘ENV’]}.example.com”);
This likely occurs because constant values cannot be defined twice. Please modify
connect_to_db()as follows to ensure correct operation:$const = get_defined_constants(true)['user'] ?? [];
$credentials = [
'db_name' => 'DB_NAME',
'db_user' => 'DB_USER',
'db_password' => 'DB_PASSWORD',
'db_host' => 'DB_HOST',
'db_charset' => 'DB_CHARSET'
];
foreach($credentials as $credential => $constant_name) {
if (isset($const[$constant_name])) {
$credentials[$credential] = $const[$constant_name];
} else {
return false;
}
}
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.