Skip to content

Commit d4b108a

Browse files
MC-33278: [Magento Cloud] - Magento\Framework\App\DeploymentConfig\Reader::load function is taking too much time
1 parent c9a246a commit d4b108a

File tree

5 files changed

+8
-14
lines changed

5 files changed

+8
-14
lines changed

dev/tests/integration/testsuite/Magento/Developer/Model/Logger/Handler/DebugTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function testDebugInDeveloperMode()
139139
{
140140
$message = 'test message';
141141
$this->reinitDebugHandler(State::MODE_DEVELOPER);
142-
142+
$this->deploymentConfig->resetData();
143143
$this->removeDebugLog();
144144
$this->logger->debug($message);
145145
$this->assertFileExists($this->getDebuggerLogPath());

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Application deployment configuration
1616
*
1717
* @api
18+
* @since 100.0.2
1819
*/
1920
class DeploymentConfig
2021
{
@@ -148,7 +149,7 @@ public function isDbAvailable()
148149
*/
149150
private function load()
150151
{
151-
if (null === $this->data) {
152+
if (empty($this->data)) {
152153
$this->data = $this->reader->load();
153154
if ($this->overrideData) {
154155
$this->data = array_replace($this->data, $this->overrideData);
@@ -183,6 +184,7 @@ private function flattenParams(array $params, $path = null, array &$flattenResul
183184
$newPath = $key;
184185
}
185186
if (isset($flattenResult[$newPath])) {
187+
//phpcs:ignore Magento2.Exceptions.DirectThrow
186188
throw new RuntimeException(new Phrase("Key collision '%1' is already defined.", [$newPath]));
187189
}
188190
$flattenResult[$newPath] = $param;

lib/internal/Magento/Framework/Locale/Resolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class Resolver implements ResolverInterface
1616
{
1717
/**
18-
* Default locale
18+
* Resolver default locale
1919
*/
2020
const DEFAULT_LOCALE = 'en_US';
2121

@@ -79,7 +79,7 @@ public function __construct(
7979
$this->scopeConfig = $scopeConfig;
8080
$this->defaultLocalePath = $defaultLocalePath;
8181
$this->scopeType = $scopeType;
82-
$this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->create(DeploymentConfig::class);
82+
$this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->get(DeploymentConfig::class);
8383
$this->setLocale($locale);
8484
}
8585

lib/internal/Magento/Framework/Module/ModuleList.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,8 @@ public function isModuleInfoAvailable()
140140
*/
141141
private function loadConfigData()
142142
{
143-
if (null === $this->configData) {
144-
$this->config->resetData();
145-
if (null !== $this->config->get(ConfigOptionsListConstants::KEY_MODULES)) {
146-
$this->configData = $this->config->get(ConfigOptionsListConstants::KEY_MODULES);
147-
}
143+
if (null === $this->configData && null !== $this->config->get(ConfigOptionsListConstants::KEY_MODULES)) {
144+
$this->configData = $this->config->get(ConfigOptionsListConstants::KEY_MODULES);
148145
}
149146
}
150147
}

lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ protected function setUp()
4747

4848
public function testGetAll()
4949
{
50-
$this->config->expects($this->once())->method('resetData');
5150
$this->setLoadAllExpectation();
5251
$this->setLoadConfigExpectation();
5352
$expected = ['foo' => self::$allFixture['foo']];
@@ -65,7 +64,6 @@ public function testGetAllNoData()
6564

6665
public function testGetOne()
6766
{
68-
$this->config->expects($this->once())->method('resetData');
6967
$this->setLoadAllExpectation();
7068
$this->setLoadConfigExpectation();
7169
$this->assertSame(['key' => 'value'], $this->model->getOne('foo'));
@@ -74,7 +72,6 @@ public function testGetOne()
7472

7573
public function testGetNames()
7674
{
77-
$this->config->expects($this->once())->method('resetData');
7875
$this->setLoadAllExpectation(false);
7976
$this->setLoadConfigExpectation();
8077
$this->assertSame(['foo'], $this->model->getNames());
@@ -83,7 +80,6 @@ public function testGetNames()
8380

8481
public function testHas()
8582
{
86-
$this->config->expects($this->once())->method('resetData');
8783
$this->setLoadAllExpectation(false);
8884
$this->setLoadConfigExpectation();
8985
$this->assertTrue($this->model->has('foo'));
@@ -92,7 +88,6 @@ public function testHas()
9288

9389
public function testIsModuleInfoAvailable()
9490
{
95-
$this->config->expects($this->once())->method('resetData');
9691
$this->setLoadConfigExpectation(true);
9792
$this->assertTrue($this->model->isModuleInfoAvailable());
9893
}

0 commit comments

Comments
 (0)