Skip to content

Commit 32c813f

Browse files
author
Pascal Querner
committed
envLoader: fix loading from scopes
1 parent 325ae2a commit 32c813f

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

app/code/core/Mage/Adminhtml/Block/System/Config/Form.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,9 @@ public function isOverwrittenByEnvVariable(string $path): bool
638638
{
639639
/** @var Mage_Core_Helper_EnvironmentConfigLoader $environmentConfigLoaderHelper */
640640
$environmentConfigLoaderHelper = Mage::helper('core/environmentConfigLoader');
641-
$path = $this->getScope() . '/' . $path;
641+
$store = Mage::app()->getRequest()->getParam('store');
642+
$scope = $this->getScope();
643+
$path = "$scope/$store/$path";
642644
return $environmentConfigLoaderHelper->hasPath($path);
643645
}
644646

app/code/core/Mage/Adminhtml/Model/Config/Data.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ protected function _getPathConfig($path, $full = true)
345345
if (!$full) {
346346
/** @var Mage_Core_Helper_EnvironmentConfigLoader $environmentConfigLoaderHelper */
347347
$environmentConfigLoaderHelper = Mage::helper('core/environmentConfigLoader');
348-
$envConfig = $environmentConfigLoaderHelper->getAsArray($this->getScope());
348+
$store = $this->getStore();
349+
$envConfig = $environmentConfigLoaderHelper->getAsArray($store);
349350
$config = array_merge($config, $envConfig);
350351
}
351352
return $config;

app/code/core/Mage/Core/Helper/EnvironmentConfigLoader.php

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function overrideEnvironment(Varien_Simplexml_Config $xmlConfig)
8282

8383
case static::CONFIG_KEY_WEBSITES:
8484
case static::CONFIG_KEY_STORES:
85-
[$unused1, $unused2, $code, $section, $group, $field] = $configKeyParts;
85+
[$unused1, $unused2, $storeCode, $section, $group, $field] = $configKeyParts;
8686
$path = $this->buildPath($section, $group, $field);
8787
$storeCode = strtolower($storeCode);
8888
$scope = strtolower($scope);
@@ -130,9 +130,11 @@ public function hasPath(string $wantedPath): bool
130130

131131
case static::CONFIG_KEY_WEBSITES:
132132
case static::CONFIG_KEY_STORES:
133-
list($unused1, $unused2, $storeCode, $section, $group, $field) = $configKeyParts;
133+
[$unused1, $unused2, $storeCode, $section, $group, $field] = $configKeyParts;
134134
$path = $this->buildPath($section, $group, $field);
135-
$nodePath = $this->buildNodePath($scope, $path);
135+
$storeCode = strtolower($storeCode);
136+
$scope = strtolower($scope);
137+
$nodePath = sprintf('%s/%s/%s', $scope, $storeCode, $path);
136138
$config[$nodePath] = $value;
137139
break;
138140
}
@@ -142,9 +144,9 @@ public function hasPath(string $wantedPath): bool
142144
return $hasConfig;
143145
}
144146

145-
public function getAsArray(string $wantedScope): array
147+
public function getAsArray(string $wantedStore): array
146148
{
147-
$data = Mage::registry("config_env_array_$wantedScope");
149+
$data = Mage::registry("config_env_array_$wantedStore");
148150
if ($data !== null) {
149151
return $data;
150152
}
@@ -157,26 +159,20 @@ public function getAsArray(string $wantedScope): array
157159
}
158160

159161
list($configKeyParts, $scope) = $this->getConfigKey($configKey);
160-
if (strtolower($scope) !== strtolower($wantedScope)) {
161-
continue;
162-
}
163162

164163
switch ($scope) {
165-
case static::CONFIG_KEY_DEFAULT:
166-
list($unused1, $unused2, $section, $group, $field) = $configKeyParts;
167-
$path = $this->buildPath($section, $group, $field);
168-
$config[$path] = $value;
169-
break;
170-
171164
case static::CONFIG_KEY_WEBSITES:
172165
case static::CONFIG_KEY_STORES:
173-
list($unused1, $unused2, $storeCode, $section, $group, $field) = $configKeyParts;
166+
[$unused1, $unused2, $storeCode, $section, $group, $field] = $configKeyParts;
167+
if (strtolower($storeCode) !== strtolower($wantedStore)) {
168+
break;
169+
}
174170
$path = $this->buildPath($section, $group, $field);
175171
$config[$path] = $value;
176172
break;
177173
}
178174
}
179-
Mage::register("config_env_array_$wantedScope", $config);
175+
Mage::register("config_env_array_$wantedStore", $config);
180176
return $config;
181177
}
182178

@@ -212,8 +208,11 @@ protected function setCache(Mage_Core_Model_Store $store, $value, string $path):
212208
$refProperty = $refObject->getProperty('_configCache');
213209
$refProperty->setAccessible(true);
214210
$configCache = $refProperty->getValue($store);
211+
if (!is_array($configCache)) {
212+
$configCache = [];
213+
}
215214
$configCache[$path] = $value;
216-
$refProperty->setValue($store, $configCache);
215+
$store->setConfigCache($configCache);
217216
}
218217

219218
protected function getConfigKey(string $configKey): array

0 commit comments

Comments
 (0)