Skip to content

Commit 5580b83

Browse files
author
Pascal Querner
committed
fix: set cache when env loader overrides data
1 parent 5e03d3c commit 5580b83

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

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

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,32 @@ public function overrideEnvironment(Varien_Simplexml_Config $xmlConfig)
6363
case static::CONFIG_KEY_DEFAULT:
6464
[$unused1, $unused2, $section, $group, $field] = $configKeyParts;
6565
$path = $this->buildPath($section, $group, $field);
66-
$xmlConfig->setNode($this->buildNodePath($scope, $path), $value);
66+
$nodePath = $this->buildNodePath($scope, $path);
67+
$xmlConfig->setNode($nodePath, $value);
68+
try {
69+
$store = Mage::app()->getStore(0);
70+
$this->setCache($store, $value, $path);
71+
} catch (Throwable $exception) {
72+
Mage::logException($exception);
73+
}
6774
break;
6875

6976
case static::CONFIG_KEY_WEBSITES:
7077
case static::CONFIG_KEY_STORES:
7178
[$unused1, $unused2, $code, $section, $group, $field] = $configKeyParts;
7279
$path = $this->buildPath($section, $group, $field);
73-
$nodePath = sprintf('%s/%s/%s', strtolower($scope), strtolower($code), $path);
80+
$storeCode = strtolower($storeCode);
81+
$scope = strtolower($scope);
82+
$nodePath = sprintf('%s/%s/%s', $scope, $storeCode, $path);
7483
$xmlConfig->setNode($nodePath, $value);
84+
try {
85+
if (!str_contains($nodePath, 'websites')) {
86+
$store = Mage::app()->getStore($storeCode);
87+
$this->setCache($store, $value, $path);
88+
}
89+
} catch (Throwable $exception) {
90+
Mage::logException($exception);
91+
}
7592
break;
7693
}
7794
}
@@ -93,6 +110,16 @@ public function getEnv(): array
93110
return $this->envStore;
94111
}
95112

113+
protected function setCache(Mage_Core_Model_Store $store, $value, string $path): void
114+
{
115+
$refObject = new ReflectionObject($store);
116+
$refProperty = $refObject->getProperty('_configCache');
117+
$refProperty->setAccessible(true);
118+
$configCache = $refProperty->getValue($store);
119+
$configCache[$path] = $value;
120+
$refProperty->setValue($store, $configCache);
121+
}
122+
96123
protected function getConfigKey(string $configKey): array
97124
{
98125
$configKeyParts = array_filter(

0 commit comments

Comments
 (0)