Skip to content

Commit 226709e

Browse files
ACPT-1599: Fixing DeploymentConfig resets & reloads every time new key that wasn't previously set
Fixing problem ACP2E-2198. ``` [Progress: 861 / 864] Disabling Maintenance Mode: In ResourceConnection.php line 162: [DomainException] Connection "default" is not defined ``` The root cause of problem is that the `Disabling Maintenance Mode` part of the install uses the first created DeploymentConfig object created in the process, which doesn't get updated, while before that runs, different part of the install that writes to the config is using the second DeploymentConfig object that was created by Laminas ServiceManager. The reason why this happens is because Intercepters use ObjectManager::getInstance to get the ObjectManager to find PluginList. This causes the plugins to use the first DeploymentConfig object which was created for the first ObjectManager. Other objects that use ObjectManager::getInstance may have this problem as well. This commit adds a workaround in main loop of Installer that calls DeploymentConfig::resetData() on the original DeploymentConfig.
1 parent 3e03cf2 commit 226709e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

setup/src/Magento/Setup/Model/Installer.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
use Magento\Framework\App\Cache\Type\Block as BlockCache;
1313
use Magento\Framework\App\Cache\Type\Config as ConfigCache;
1414
use Magento\Framework\App\Cache\Type\Layout as LayoutCache;
15+
use Magento\Framework\App\DeploymentConfig;
1516
use Magento\Framework\App\DeploymentConfig\Reader;
1617
use Magento\Framework\App\DeploymentConfig\Writer;
1718
use Magento\Framework\App\Filesystem\DirectoryList;
1819
use Magento\Framework\App\MaintenanceMode;
20+
use Magento\Framework\App\ObjectManager;
1921
use Magento\Framework\App\State\CleanupFiles;
2022
use Magento\Framework\Component\ComponentRegistrar;
2123
use Magento\Framework\Config\ConfigOptionsListConstants;
@@ -175,10 +177,15 @@ class Installer
175177
private $installInfo = [];
176178

177179
/**
178-
* @var \Magento\Framework\App\DeploymentConfig
180+
* @var DeploymentConfig
179181
*/
180182
private $deploymentConfig;
181183

184+
/**
185+
* @var DeploymentConfig
186+
*/
187+
private $firstDeploymentConfig;
188+
182189
/**
183190
* @var ObjectManagerProvider
184191
*/
@@ -327,6 +334,11 @@ public function __construct(
327334
$this->phpReadinessCheck = $phpReadinessCheck;
328335
$this->schemaPersistor = $this->objectManagerProvider->get()->get(SchemaPersistor::class);
329336
$this->triggerCleaner = $this->objectManagerProvider->get()->get(TriggerCleaner::class);
337+
/* Note: Because this class is dependency injected with Laminas ServiceManager, but our plugins, and some
338+
* other classes also use the App\ObjectManager instead, we have to make sure that the DeploymentConfig object
339+
* from that ObjectManager gets reset as different steps in the installer will write to the deployment config.
340+
*/
341+
$this->firstDeploymentConfig = ObjectManager::getInstance()->get(DeploymentConfig::class);
330342
}
331343

332344
/**
@@ -381,6 +393,9 @@ public function install($request)
381393
$this->log->log('Starting Magento installation:');
382394

383395
foreach ($script as $item) {
396+
/* Note: Because the $this->DeploymentConfig gets written to, but plugins use $this->firstDeploymentConfig,
397+
* we have to reset this one after each item of $script so the plugins will see the config updates. */
398+
$this->firstDeploymentConfig->resetData();
384399
list($message, $method, $params) = $item;
385400
$this->log->log($message);
386401
try {

0 commit comments

Comments
 (0)