Skip to content

Commit 773e35f

Browse files
committed
BUG#AC-901: Cant install Magento in interactive mode
1 parent 2e742ec commit 773e35f

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ private function interactiveQuestions(InputInterface $input, OutputInterface $ou
363363
/**
364364
* Runs interactive questions
365365
*
366-
* It will ask users for interactive questionst regarding setup configuration.
366+
* It will ask users for interactive questions regarding setup configuration.
367367
*
368368
* @param InputInterface $input
369369
* @param OutputInterface $output
@@ -410,14 +410,11 @@ private function askQuestion(
410410
$question->setValidator(function ($answer) use ($option, $validateInline) {
411411

412412
if ($option instanceof \Magento\Framework\Setup\Option\SelectConfigOption) {
413-
$answer = $option->getSelectOptions()[$answer];
413+
//If user doesn't provide an input & default value for question is not set, take first option as input.
414+
$answer = $option->getSelectOptions()[$answer] ?? current($option->getSelectOptions());
414415
}
415416

416-
if ($answer == null) {
417-
$answer = '';
418-
} else {
419-
$answer = is_string($answer) ? trim($answer) : $answer;
420-
}
417+
$answer = $answer === null ? '' : (is_string($answer) ? trim($answer) : $answer);
421418

422419
if ($validateInline) {
423420
$option->validate($answer);

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\App\DeploymentConfig\Writer;
1212
use Magento\Framework\Setup\Option\AbstractConfigOption;
1313
use Magento\Framework\Setup\FilePermissions;
14+
use \Magento\Setup\Exception as SetupException;
1415

1516
class ConfigModel
1617
{
@@ -68,9 +69,11 @@ public function getAvailableOptions()
6869
$optionLists = $this->collector->collectOptionsLists();
6970

7071
foreach ($optionLists as $optionList) {
71-
$optionCollection = array_merge($optionCollection, $optionList->getOptions());
72+
$optionCollection[] = $optionList->getOptions();
7273
}
7374

75+
$optionCollection = array_merge([], ...$optionCollection);
76+
7477
foreach ($optionCollection as $option) {
7578
$currentValue = $this->deploymentConfig->get($option->getConfigPath());
7679
if ($currentValue !== null) {
@@ -100,7 +103,7 @@ public function process($inputOptions)
100103
foreach ($configData as $config) {
101104
$fileConfigStorage = [];
102105
if (!$config instanceof ConfigData) {
103-
throw new \Exception(
106+
throw new SetupException(
104107
'In module : '
105108
. $moduleName
106109
. 'ConfigOption::createConfig should return an array of ConfigData instances'
@@ -149,10 +152,10 @@ public function validate(array $inputOptions)
149152
$options = $this->collector->collectOptionsLists();
150153

151154
foreach ($options as $option) {
152-
$errors = array_merge($errors, $option->validate($inputOptions, $this->deploymentConfig));
155+
$errors[] = $option->validate($inputOptions, $this->deploymentConfig);
153156
}
154157

155-
return $errors;
158+
return array_merge([], ...$errors);
156159
}
157160

158161
/**
@@ -166,7 +169,7 @@ private function checkInstallationFilePermissions()
166169
$results = $this->filePermissions->getMissingWritablePathsForInstallation();
167170
if ($results) {
168171
$errorMsg = "Missing write permissions to the following paths:" . PHP_EOL . implode(PHP_EOL, $results);
169-
throw new \Exception($errorMsg);
172+
throw new SetupException($errorMsg);
170173
}
171174
}
172175
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ public function validate(array $options, DeploymentConfig $deploymentConfig)
252252
$errors[] = $this->validateDbPrefix($options[ConfigOptionsListConstants::INPUT_KEY_DB_PREFIX]);
253253
}
254254

255-
if ($options[ConfigOptionsListConstants::INPUT_KEY_SKIP_DB_VALIDATION] ?? false) {
255+
if (isset($options[ConfigOptionsListConstants::INPUT_KEY_SKIP_DB_VALIDATION]) &&
256+
!$options[ConfigOptionsListConstants::INPUT_KEY_SKIP_DB_VALIDATION]) {
256257
$errors[] = $this->validateDbSettings($options, $deploymentConfig);
257258
}
258259

0 commit comments

Comments
 (0)