simplify logic, fullfills the unit test

This commit is contained in:
El RIDO 2019-12-25 08:11:25 +01:00
parent 07a6e3094d
commit 0efe6f7a8e
No known key found for this signature in database
GPG Key ID: 0F5C940A6BD81F92

View File

@ -102,29 +102,10 @@ class Configuration
public function __construct()
{
$config = array();
$basePath = PATH . 'cfg' . DIRECTORY_SEPARATOR;
$basePath = (getenv('CONFIG_PATH') !== false ? getenv('CONFIG_PATH') : PATH . 'cfg') . DIRECTORY_SEPARATOR;
$configIni = $basePath . 'conf.ini';
$configFile = $basePath . 'conf.php';
if (getenv('CONFIG_PATH') !== false) {
$configFile = getenv('CONFIG_PATH');
$configFilePhp = substr($configFile, 0, -3) . 'php';
// Rename INI files to avoid configuration leakage
if (
strtolower(substr($configFile, -3, 3)) == 'ini' &&
is_readable($configFile) &&
is_writable(dirname($configFile))
) {
DataStore::prependRename($configFile, $configFilePhp, ';');
}
// Rename successful? Already renamed? use that file
if (is_readable($configFilePhp)) {
$configFile = $configFilePhp;
}
}
// rename INI files to avoid configuration leakage
if (is_readable($configIni)) {
DataStore::prependRename($configIni, $configFile, ';');