Skip to content

Commit dd6bcfb

Browse files
Oleksandr Gorkuncpartica
authored andcommitted
MAGETWO-95880: Fail to install Magento 2.3.0 on cloud
1 parent 1be7b04 commit dd6bcfb

File tree

1 file changed

+37
-8
lines changed

1 file changed

+37
-8
lines changed

app/code/Magento/Config/App/Config/Type/System.php

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,32 @@ public function get($path = '')
131131
return $this->getWithParts($path);
132132
}
133133

134+
/**
135+
* Merge newly loaded config data into already loaded.
136+
*
137+
* @param array $newData
138+
* @return void
139+
*/
140+
private function mergeData(array $newData): void
141+
{
142+
if (array_key_exists(ScopeInterface::SCOPE_DEFAULT, $newData)) {
143+
//Sometimes new data may contain links to arrays and we don't want that.
144+
$this->data[ScopeInterface::SCOPE_DEFAULT] = (array)$newData[ScopeInterface::SCOPE_DEFAULT];
145+
unset($newData[ScopeInterface::SCOPE_DEFAULT]);
146+
}
147+
foreach ($newData as $scopeType => $scopeTypeData) {
148+
if (!array_key_exists($scopeType, $this->data)) {
149+
//Sometimes new data may contain links to arrays and we don't want that.
150+
$this->data[$scopeType] = (array)$scopeTypeData;
151+
} else {
152+
foreach ($scopeTypeData as $scopeId => $scopeData) {
153+
//Sometimes new data may contain links to arrays and we don't want that.
154+
$this->data[$scopeType][$scopeId] = (array)$scopeData;
155+
}
156+
}
157+
}
158+
}
159+
134160
/**
135161
* Proceed with parts extraction from path.
136162
*
@@ -143,8 +169,10 @@ private function getWithParts($path)
143169

144170
if (count($pathParts) === 1 && $pathParts[0] !== ScopeInterface::SCOPE_DEFAULT) {
145171
if (!isset($this->data[$pathParts[0]])) {
172+
//First filling data property with unprocessed data for post-processors to be able to use.
146173
$data = $this->readData();
147-
$this->data = array_replace_recursive($this->data, $this->postProcessor->process($data));
174+
//Post-processing only the data we know is not yet processed.
175+
$this->mergeData($this->postProcessor->process($data));
148176
}
149177

150178
return $this->data[$pathParts[0]];
@@ -154,12 +182,11 @@ private function getWithParts($path)
154182

155183
if ($scopeType === ScopeInterface::SCOPE_DEFAULT) {
156184
if (!isset($this->data[$scopeType])) {
157-
$this->data = array_replace_recursive(
158-
$this->data,
159-
$scopeData = $this->loadDefaultScopeData($scopeType)
160-
);
185+
//Adding unprocessed data to the data property so it can be used in post-processing.
186+
$this->mergeData($scopeData = $this->loadDefaultScopeData($scopeType));
187+
//Only post-processing the data we know is raw.
161188
$scopeData = $this->postProcessor->process($scopeData);
162-
$this->data = array_replace_recursive($this->data, $scopeData);
189+
$this->mergeData($scopeData);
163190
}
164191

165192
return $this->getDataByPathParts($this->data[$scopeType], $pathParts);
@@ -169,9 +196,11 @@ private function getWithParts($path)
169196

170197
if (!isset($this->data[$scopeType][$scopeId])) {
171198
$scopeData = $this->loadScopeData($scopeType, $scopeId);
172-
$this->data = array_replace_recursive($this->data, $scopeData);
199+
//Adding unprocessed data to the data property so it can be used in post-processing.
200+
$this->mergeData($scopeData);
201+
//Only post-processing the data we know is raw.
173202
$scopeData = $this->postProcessor->process($scopeData);
174-
$this->data = array_replace_recursive($this->data, $scopeData);
203+
$this->mergeData($scopeData);
175204
}
176205

177206
return isset($this->data[$scopeType][$scopeId])

0 commit comments

Comments
 (0)