From 97d70bf0cb504bd7b031e57fea74d049b6a1f174 Mon Sep 17 00:00:00 2001 From: Thomas Steur <thomas.steur@gmail.com> Date: Wed, 9 Sep 2015 11:01:34 +0000 Subject: [PATCH] fix saving config does not work, we need to remove a reference BTW: The method name Config::forceSave is kinda wrong as it does not force anything, it saves only if there is a change --- core/Config/IniFileChain.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/core/Config/IniFileChain.php b/core/Config/IniFileChain.php index d8b4e4e28b..b69154049f 100644 --- a/core/Config/IniFileChain.php +++ b/core/Config/IniFileChain.php @@ -222,7 +222,23 @@ class IniFileChain } } - $this->mergedSettings = $this->mergeFileSettings(); + $merged = $this->mergeFileSettings(); + // remove reference to $this->settingsChain... otherwise dump() or compareElements() will never notice a difference + // on PHP 7+ as they would be always equal + $this->mergedSettings = $this->copy($merged); + } + + private function copy($merged) + { + $copy = array(); + foreach ($merged as $index => $value) { + if (is_array($value)) { + $copy[$index] = $this->copy($value); + } else { + $copy[$index] = $value; + } + } + return $copy; } private function resetSettingsChain($defaultSettingsFiles, $userSettingsFile) -- GitLab