|
| 1 | +diff -Nuar a/vendor/magento/framework/App/DeploymentConfig.php b/vendor/magento/framework/App/DeploymentConfig.php |
| 2 | +index 6713baa3a1d..64f32d5516b 100644 |
| 3 | +--- a/vendor/magento/framework/App/DeploymentConfig.php |
| 4 | ++++ b/vendor/magento/framework/App/DeploymentConfig.php |
| 5 | +@@ -51,6 +51,16 @@ class DeploymentConfig |
| 6 | + */ |
| 7 | + private $overrideData; |
| 8 | + |
| 9 | ++ /** |
| 10 | ++ * @var array |
| 11 | ++ */ |
| 12 | ++ private $envOverrides = []; |
| 13 | ++ |
| 14 | ++ /** |
| 15 | ++ * @var array |
| 16 | ++ */ |
| 17 | ++ private $readerLoad = []; |
| 18 | ++ |
| 19 | + /** |
| 20 | + * Constructor |
| 21 | + * |
| 22 | +@@ -84,7 +94,9 @@ class DeploymentConfig |
| 23 | + } |
| 24 | + $result = $this->getByKey($key); |
| 25 | + if ($result === null) { |
| 26 | +- $this->reloadData(); |
| 27 | ++ if (empty($this->flatData) || count($this->getAllEnvOverrides())) { |
| 28 | ++ $this->reloadData(); |
| 29 | ++ } |
| 30 | + $result = $this->getByKey($key); |
| 31 | + } |
| 32 | + return $result ?? $defaultValue; |
| 33 | +@@ -114,13 +126,13 @@ class DeploymentConfig |
| 34 | + { |
| 35 | + if ($key === null) { |
| 36 | + if (empty($this->data)) { |
| 37 | +- $this->reloadData(); |
| 38 | ++ $this->reloadInitialData(); |
| 39 | + } |
| 40 | + return $this->data; |
| 41 | + } |
| 42 | + $result = $this->getConfigDataByKey($key); |
| 43 | + if ($result === null) { |
| 44 | +- $this->reloadData(); |
| 45 | ++ $this->reloadInitialData(); |
| 46 | + $result = $this->getConfigDataByKey($key); |
| 47 | + } |
| 48 | + return $result; |
| 49 | +@@ -170,28 +182,55 @@ class DeploymentConfig |
| 50 | + * @throws FileSystemException |
| 51 | + * @throws RuntimeException |
| 52 | + */ |
| 53 | +- private function reloadData(): void |
| 54 | ++ private function reloadInitialData(): void |
| 55 | + { |
| 56 | ++ if (empty($this->readerLoad) || empty($this->data) || empty($this->flatData)) { |
| 57 | ++ $this->readerLoad = $this->reader->load(); |
| 58 | ++ } |
| 59 | + $this->data = array_replace( |
| 60 | +- $this->reader->load(), |
| 61 | ++ $this->readerLoad, |
| 62 | + $this->overrideData ?? [], |
| 63 | + $this->getEnvOverride() |
| 64 | + ); |
| 65 | ++ } |
| 66 | ++ |
| 67 | ++ /** |
| 68 | ++ * Loads the configuration data |
| 69 | ++ * |
| 70 | ++ * @return void |
| 71 | ++ * @throws FileSystemException |
| 72 | ++ * @throws RuntimeException |
| 73 | ++ */ |
| 74 | ++ private function reloadData(): void |
| 75 | ++ { |
| 76 | ++ $this->reloadInitialData(); |
| 77 | + // flatten data for config retrieval using get() |
| 78 | + $this->flatData = $this->flattenParams($this->data); |
| 79 | ++ $this->flatData = $this->getAllEnvOverrides() + $this->flatData; |
| 80 | ++ } |
| 81 | + |
| 82 | +- // allow reading values from env variables by convention |
| 83 | +- // MAGENTO_DC_{path}, like db/connection/default/host => |
| 84 | +- // can be overwritten by MAGENTO_DC_DB__CONNECTION__DEFAULT__HOST |
| 85 | +- foreach (getenv() as $key => $value) { |
| 86 | +- if (false !== \strpos($key, self::MAGENTO_ENV_PREFIX) |
| 87 | +- && $key !== self::OVERRIDE_KEY |
| 88 | +- ) { |
| 89 | +- // convert MAGENTO_DC_DB__CONNECTION__DEFAULT__HOST into db/connection/default/host |
| 90 | +- $flatKey = strtolower(str_replace([self::MAGENTO_ENV_PREFIX, '__'], ['', '/'], $key)); |
| 91 | +- $this->flatData[$flatKey] = $value; |
| 92 | ++ /** |
| 93 | ++ * Load all getenv() configs once |
| 94 | ++ * |
| 95 | ++ * @return array |
| 96 | ++ */ |
| 97 | ++ private function getAllEnvOverrides(): array |
| 98 | ++ { |
| 99 | ++ if (empty($this->envOverrides)) { |
| 100 | ++ // allow reading values from env variables by convention |
| 101 | ++ // MAGENTO_DC_{path}, like db/connection/default/host => |
| 102 | ++ // can be overwritten by MAGENTO_DC_DB__CONNECTION__DEFAULT__HOST |
| 103 | ++ foreach (getenv() as $key => $value) { |
| 104 | ++ if (false !== \strpos($key, self::MAGENTO_ENV_PREFIX) |
| 105 | ++ && $key !== self::OVERRIDE_KEY |
| 106 | ++ ) { |
| 107 | ++ // convert MAGENTO_DC_DB__CONNECTION__DEFAULT__HOST into db/connection/default/host |
| 108 | ++ $flatKey = strtolower(str_replace([self::MAGENTO_ENV_PREFIX, '__'], ['', '/'], $key)); |
| 109 | ++ $this->envOverrides[$flatKey] = $value; |
| 110 | ++ } |
| 111 | + } |
| 112 | + } |
| 113 | ++ return $this->envOverrides; |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | +diff -Nuar a/vendor/magento/framework/Module/ModuleList.php b/vendor/magento/framework/Module/ModuleList.php |
| 118 | +index b3cf433bbaf..32e2d2b1550 100644 |
| 119 | +--- a/vendor/magento/framework/Module/ModuleList.php |
| 120 | ++++ b/vendor/magento/framework/Module/ModuleList.php |
| 121 | +@@ -140,8 +140,11 @@ class ModuleList implements ModuleListInterface |
| 122 | + */ |
| 123 | + private function loadConfigData() |
| 124 | + { |
| 125 | +- if (null === $this->configData && null !== $this->config->get(ConfigOptionsListConstants::KEY_MODULES)) { |
| 126 | +- $this->configData = $this->config->get(ConfigOptionsListConstants::KEY_MODULES); |
| 127 | ++ if (null === $this->configData) { |
| 128 | ++ $config = $this->config->get(ConfigOptionsListConstants::KEY_MODULES); |
| 129 | ++ if (null !== $config) { |
| 130 | ++ $this->configData = $config; |
| 131 | ++ } |
| 132 | + } |
| 133 | + } |
| 134 | + } |
0 commit comments