Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiosmosis <benaka@piwik.pro>2015-03-15 22:07:58 +0300
committerdiosmosis <benaka@piwik.pro>2015-03-15 22:07:58 +0300
commit9dc5238cc8e1e5af775e5f1f934c05c30bff74b9 (patch)
treeed08cce1f03b84bec0c337ebadf82431384ed82f /core/Config
parentc923086d8ae13a0773f1c2098bbfa0a781f75dde (diff)
Force sections in INI file output to be ordered by when sections appear in file chain.
Diffstat (limited to 'core/Config')
-rw-r--r--core/Config/IniFileChain.php28
1 files changed, 27 insertions, 1 deletions
diff --git a/core/Config/IniFileChain.php b/core/Config/IniFileChain.php
index 9eaae3e9ff..6497bf2b0c 100644
--- a/core/Config/IniFileChain.php
+++ b/core/Config/IniFileChain.php
@@ -159,7 +159,20 @@ class IniFileChain
}
if ($dirty) {
- @uksort($configToWrite, "strnatcasecmp");
+ // sort config sections by how early they appear in the file chain
+ $self = $this;
+ uksort($configToWrite, function ($sectionNameLhs, $sectionNameRhs) use ($self) {
+ $lhsIndex = $self->findIndexOfFirstFileWithSection($sectionNameLhs);
+ $rhsIndex = $self->findIndexOfFirstFileWithSection($sectionNameRhs);
+
+ if ($lhsIndex == $rhsIndex) {
+ return 0;
+ } else if ($lhsIndex < $rhsIndex) {
+ return -1;
+ } else {
+ return 1;
+ }
+ });
$writer = new IniWriter();
return $writer->writeToString($configToWrite, $header);
@@ -340,4 +353,17 @@ class IniFileChain
}
return $merged;
}
+
+ public function findIndexOfFirstFileWithSection($sectionName)
+ {
+ $count = 0;
+ foreach ($this->settingsChain as $file => $settings) {
+ if (isset($settings[$sectionName])) {
+ break;
+ }
+
+ ++$count;
+ }
+ return $count;
+ }
} \ No newline at end of file