Skip to content

Commit 1982e0c

Browse files
MC-34416: Error in the CLI during upgrade
1 parent 28315e7 commit 1982e0c

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

setup/src/Magento/Setup/Console/Command/UpgradeCommand.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\App\State as AppState;
1010
use Magento\Framework\App\DeploymentConfig;
1111
use Magento\Framework\App\ObjectManager;
12+
use Magento\Framework\Config\CacheInterface;
1213
use Magento\Framework\Setup\ConsoleLogger;
1314
use Magento\Framework\Setup\Declaration\Schema\DryRunLogger;
1415
use Magento\Framework\Setup\Declaration\Schema\OperationsExecutor;
@@ -52,22 +53,30 @@ class UpgradeCommand extends AbstractSetupCommand
5253
*/
5354
private $searchConfigFactory;
5455

56+
/*
57+
* @var CacheInterface
58+
*/
59+
private $cache;
60+
5561
/**
5662
* @param InstallerFactory $installerFactory
5763
* @param SearchConfigFactory $searchConfigFactory
5864
* @param DeploymentConfig $deploymentConfig
5965
* @param AppState|null $appState
66+
* @param CacheInterface|null $cache
6067
*/
6168
public function __construct(
6269
InstallerFactory $installerFactory,
6370
SearchConfigFactory $searchConfigFactory,
6471
DeploymentConfig $deploymentConfig = null,
65-
AppState $appState = null
72+
AppState $appState = null,
73+
CacheInterface $cache = null
6674
) {
6775
$this->installerFactory = $installerFactory;
6876
$this->searchConfigFactory = $searchConfigFactory;
6977
$this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->get(DeploymentConfig::class);
7078
$this->appState = $appState ?: ObjectManager::getInstance()->get(AppState::class);
79+
$this->cache = $cache ?: ObjectManager::getInstance()->get(CacheInterface::class);
7180
parent::__construct();
7281
}
7382

@@ -129,6 +138,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
129138
$installer = $this->installerFactory->create(new ConsoleLogger($output));
130139
$installer->updateModulesSequence($keepGenerated);
131140
$searchConfig = $this->searchConfigFactory->create();
141+
$this->cache->clean();
132142
$searchConfig->validateSearchEngine();
133143
$installer->installSchema($request);
134144
$installer->installDataFixtures($request);

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Magento\Setup\Model;
99

10-
use Magento\Framework\Config\CacheInterface;
1110
use Magento\Framework\Setup\Option\AbstractConfigOption;
1211
use Magento\Framework\Validation\ValidationException;
1312
use Magento\Search\Model\SearchEngine\Validator;
@@ -34,27 +33,19 @@ class SearchConfig
3433
*/
3534
private $installConfig;
3635

37-
/**
38-
* @var CacheInterface
39-
*/
40-
private $cache;
41-
4236
/**
4337
* @param SearchConfigOptionsList $searchConfigOptionsList
4438
* @param Validator $searchValidator
4539
* @param CompositeInstallConfig $installConfig
46-
* @param CacheInterface $cache
4740
*/
4841
public function __construct(
4942
SearchConfigOptionsList $searchConfigOptionsList,
5043
Validator $searchValidator,
51-
CompositeInstallConfig $installConfig,
52-
CacheInterface $cache
44+
CompositeInstallConfig $installConfig
5345
) {
5446
$this->searchConfigOptionsList = $searchConfigOptionsList;
5547
$this->searchValidator = $searchValidator;
5648
$this->installConfig = $installConfig;
57-
$this->cache = $cache;
5849
}
5950

6051
/**
@@ -85,9 +76,6 @@ public function saveConfiguration(array $inputOptions)
8576
*/
8677
public function validateSearchEngine()
8778
{
88-
// Clean config cache prior to validation
89-
$this->cache->clean();
90-
9179
$validationErrors = $this->searchValidator->validate();
9280
if (!empty($validationErrors)) {
9381
throw new ValidationException(__(implode(PHP_EOL, $validationErrors)));

0 commit comments

Comments
 (0)