Skip to content

Commit 85907b5

Browse files
author
Pascal Querner
committed
fix: set cache when env loader overrides data
1 parent 7c8a3e5 commit 85907b5

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

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

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,32 @@ public function overrideEnvironment(Varien_Simplexml_Config $xmlConfig)
7070
case static::CONFIG_KEY_DEFAULT:
7171
list($unused1, $unused2, $section, $group, $field) = $configKeyParts;
7272
$path = $this->buildPath($section, $group, $field);
73-
$xmlConfig->setNode($this->buildNodePath($scope, $path), $value);
73+
$nodePath = $this->buildNodePath($scope, $path);
74+
$xmlConfig->setNode($nodePath, $value);
75+
try {
76+
$store = Mage::app()->getStore(0);
77+
$this->setCache($store, $value, $path);
78+
} catch (Throwable $exception) {
79+
Mage::logException($exception);
80+
}
7481
break;
7582

7683
case static::CONFIG_KEY_WEBSITES:
7784
case static::CONFIG_KEY_STORES:
78-
list($unused1, $unused2, $code, $section, $group, $field) = $configKeyParts;
85+
list($unused1, $unused2, $storeCode, $section, $group, $field) = $configKeyParts;
7986
$path = $this->buildPath($section, $group, $field);
80-
$nodePath = sprintf('%s/%s/%s', strtolower($scope), strtolower($code), $path);
87+
$storeCode = strtolower($storeCode);
88+
$scope = strtolower($scope);
89+
$nodePath = sprintf('%s/%s/%s', $scope, $storeCode, $path);
8190
$xmlConfig->setNode($nodePath, $value);
91+
try {
92+
if (!str_contains($nodePath, 'websites')) {
93+
$store = Mage::app()->getStore($storeCode);
94+
$this->setCache($store, $value, $path);
95+
}
96+
} catch (Throwable $exception) {
97+
Mage::logException($exception);
98+
}
8299
break;
83100
}
84101
}
@@ -100,6 +117,16 @@ public function getEnv(): array
100117
return $this->envStore;
101118
}
102119

120+
protected function setCache(Mage_Core_Model_Store $store, $value, string $path): void
121+
{
122+
$refObject = new ReflectionObject($store);
123+
$refProperty = $refObject->getProperty('_configCache');
124+
$refProperty->setAccessible(true);
125+
$configCache = $refProperty->getValue($store);
126+
$configCache[$path] = $value;
127+
$refProperty->setValue($store, $configCache);
128+
}
129+
103130
protected function getConfigKey(string $configKey): array
104131
{
105132
$configKeyParts = array_filter(

0 commit comments

Comments
 (0)