Skip to content

Commit 0b4c159

Browse files
authored
MCLOUD-5650: Magento\Framework\App\DeploymentConfig\Reader::load function is taking too much time (#36)
1 parent ba0dbe2 commit 0b4c159

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

patches.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@
230230
"FPC is getting disabled during deployments": {
231231
">=2.3.2 <2.3.5": "MAGECLOUD-5069__fpc_is_getting_disabled_during_deployments__2.3.2.patch",
232232
">=2.3.5 <2.4.0": "MAGECLOUD-5069__fpc_is_getting_disabled_during_deployments__2.3.5.patch"
233+
},
234+
"Hold deployment config after reading from file": {
235+
">=2.3.3 <2.3.6": "MCLOUD-5650__hold_deployment_config_after_reading_from_file.patch"
233236
}
234237
},
235238
"magento/module-paypal": {
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
diff -Nuar a/vendor/magento/framework/App/DeploymentConfig.php b/vendor/magento/framework/App/DeploymentConfig.php
2+
--- a/vendor/magento/framework/App/DeploymentConfig.php
3+
+++ b/vendor/magento/framework/App/DeploymentConfig.php
4+
@@ -86,7 +86,6 @@ public function get($key = null, $defaultValue = null)
5+
*/
6+
public function isAvailable()
7+
{
8+
- $this->data = null;
9+
$this->load();
10+
return isset($this->flatData[ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE]);
11+
}
12+
@@ -141,7 +140,7 @@ public function isDbAvailable()
13+
*/
14+
private function load()
15+
{
16+
- if (null === $this->data) {
17+
+ if (empty($this->data)) {
18+
$this->data = $this->reader->load();
19+
if ($this->overrideData) {
20+
$this->data = array_replace($this->data, $this->overrideData);
21+
@@ -173,10 +172,12 @@ private function flattenParams(array $params, $path = null)
22+
$newPath = $key;
23+
}
24+
if (isset($cache[$newPath])) {
25+
+ //phpcs:ignore Magento2.Exceptions.DirectThrow
26+
throw new \Exception("Key collision {$newPath} is already defined.");
27+
}
28+
$cache[$newPath] = $param;
29+
if (is_array($param)) {
30+
+ //phpcs:ignore Magento2.Performance.ForeachArrayMerge
31+
$cache = array_merge($cache, $this->flattenParams($param, $newPath));
32+
}
33+
}
34+
diff -Nuar a/vendor/magento/framework/Locale/Resolver.php b/vendor/magento/framework/Locale/Resolver.php
35+
--- a/vendor/magento/framework/Locale/Resolver.php
36+
+++ b/vendor/magento/framework/Locale/Resolver.php
37+
@@ -15,7 +15,7 @@
38+
class Resolver implements ResolverInterface
39+
{
40+
/**
41+
- * Default locale
42+
+ * Resolver default locale
43+
*/
44+
const DEFAULT_LOCALE = 'en_US';
45+
46+
@@ -79,7 +79,7 @@ public function __construct(
47+
$this->scopeConfig = $scopeConfig;
48+
$this->defaultLocalePath = $defaultLocalePath;
49+
$this->scopeType = $scopeType;
50+
- $this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->create(DeploymentConfig::class);
51+
+ $this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->get(DeploymentConfig::class);
52+
$this->setLocale($locale);
53+
}
54+
55+
diff -Nuar a/vendor/magento/framework/Module/ModuleList.php b/vendor/magento/framework/Module/ModuleList.php
56+
--- a/vendor/magento/framework/Module/ModuleList.php
57+
+++ b/vendor/magento/framework/Module/ModuleList.php
58+
@@ -59,7 +59,7 @@ public function __construct(DeploymentConfig $config, ModuleList\Loader $loader)
59+
}
60+
61+
/**
62+
- * {@inheritdoc}
63+
+ * @inheritdoc
64+
*
65+
* Note that this triggers loading definitions of all existing modules in the system.
66+
* Use this method only when you actually need modules' declared meta-information.
67+
@@ -84,7 +84,8 @@ public function getAll()
68+
}
69+
70+
/**
71+
- * {@inheritdoc}
72+
+ * @inheritdoc
73+
+ *
74+
* @see has()
75+
*/
76+
public function getOne($name)
77+
@@ -94,7 +95,7 @@ public function getOne($name)
78+
}
79+
80+
/**
81+
- * {@inheritdoc}
82+
+ * @inheritdoc
83+
*/
84+
public function getNames()
85+
{
86+
@@ -107,7 +108,7 @@ public function getNames()
87+
}
88+
89+
/**
90+
- * {@inheritdoc}
91+
+ * @inheritdoc
92+
*/
93+
public function has($name)
94+
{
95+
@@ -139,7 +140,6 @@ public function isModuleInfoAvailable()
96+
*/
97+
private function loadConfigData()
98+
{
99+
- $this->config->resetData();
100+
if (null === $this->configData && null !== $this->config->get(ConfigOptionsListConstants::KEY_MODULES)) {
101+
$this->configData = $this->config->get(ConfigOptionsListConstants::KEY_MODULES);
102+
}

0 commit comments

Comments
 (0)