From 7d9ec9509bce892325efe4c753065fc0f3ff1515 Mon Sep 17 00:00:00 2001 From: Lucas Savva Date: Tue, 24 Dec 2019 19:11:38 +0000 Subject: [PATCH] Handle previously renamed CONFIG_PATH gracefully --- lib/Configuration.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/Configuration.php b/lib/Configuration.php index 533cb17..5c50587 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -107,7 +107,8 @@ class Configuration $configFile = $basePath . 'conf.php'; if (getenv('CONFIG_PATH') !== false) { - $configFile = getenv('CONFIG_PATH'); + $configFile = getenv('CONFIG_PATH'); + $configFilePhp = substr($configFile, 0, -3) . 'php'; // Rename INI files to avoid configuration leakage if ( @@ -115,9 +116,12 @@ class Configuration is_readable($configFile) && is_writable(dirname($configFile)) ) { - $oldConfigFile = $configFile; - $configFile = substr($configFile, 0, -3) . 'php'; - DataStore::prependRename($oldConfigFile, $configFile, ';'); + DataStore::prependRename($configFile, $configFilePhp, ';'); + } + + // Rename successful? Already renamed? use that file + if (is_readable($configFilePhp)) { + $configFile = $configFilePhp; } }