Skip to content

Commit c1cefe7

Browse files
ISSE-33802: load config on empty cache only
1 parent 597b769 commit c1cefe7

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

lib/internal/Magento/Framework/App/DeploymentConfig.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class DeploymentConfig
3838
*
3939
* @var array
4040
*/
41-
private $flatData;
41+
private $flatData = [];
4242

4343
/**
4444
* Injected configuration data
@@ -72,7 +72,6 @@ public function __construct(DeploymentConfig\Reader $reader, $overrideData = [])
7272
*/
7373
public function get($key = null, $defaultValue = null)
7474
{
75-
$this->load();
7675
$result = $this->getByKey($key);
7776
if ($result === null) {
7877
$this->resetData();
@@ -201,9 +200,8 @@ private function flattenParams(array $params, $path = null, array &$flattenResul
201200
protected function getByKey($key)
202201
{
203202
if ($key === null) {
204-
return $this->flatData;
203+
return $this->flatData ?: null;
205204
}
206-
207205
if (array_key_exists($key, $this->flatData) && $this->flatData[$key] === null) {
208206
return '';
209207
}

lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfigTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function keyCollisionDataProvider(): array
163163

164164
public function testResetData(): void
165165
{
166-
$this->readerMock->expects($this->exactly(2))->method('load')->willReturn(self::$fixture);
166+
$this->readerMock->expects($this->once())->method('load')->willReturn(self::$fixture);
167167
$this->assertSame(self::$flattenedFixture, $this->_deploymentConfig->get());
168168
$this->_deploymentConfig->resetData();
169169
// second time to ensure loader will be invoked only once after reset
@@ -179,9 +179,9 @@ public function testIsDbAvailable(): void
179179
$this->assertTrue($this->_deploymentConfig->isDbAvailable());
180180
}
181181

182-
public function testReloadDataOnMissingConfig(): void
182+
public function testResetDataOnMissingConfig(): void
183183
{
184-
$this->readerMock->expects($this->exactly(2))->method('load')->willReturn(self::$fixture);
184+
$this->readerMock->expects($this->once())->method('load')->willReturn(self::$fixture);
185185
$defaultValue = 'some_default_value';
186186
$result = $this->_deploymentConfig->get('missing/key', $defaultValue);
187187
$this->assertEquals($defaultValue, $result);

0 commit comments

Comments
 (0)