From 0efe6f7a8e57817453fbc1f109d63ef76d08a2e7 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Wed, 25 Dec 2019 08:11:25 +0100 Subject: [PATCH] simplify logic, fullfills the unit test --- lib/Configuration.php | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/lib/Configuration.php b/lib/Configuration.php index 5c505876..9d2fd00d 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -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, ';');