Skip to content

Commit

Permalink
When the mysql import fails, make db:import fail as well
Browse files Browse the repository at this point in the history
  • Loading branch information
hostep authored and cmuench committed Dec 21, 2020
1 parent 33d5a59 commit a5f0b9d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/N98/Magento/Command/Database/ImportCommand.php
Expand Up @@ -160,11 +160,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
$dbHelper->dropTables($output);
}

$this->doImport($output, $fileName, $exec);
$success = $this->doImport($output, $fileName, $exec);

if ($input->getOption('optimize')) {
unlink($fileName);
}

return $success ? 0 : 1;
}

public function asText()
Expand Down Expand Up @@ -194,10 +196,12 @@ protected function checkFilename(InputInterface $input)
* @param string $fileName
* @param string $exec
*
* @return void
* @return bool
*/
protected function doImport(OutputInterface $output, $fileName, $exec)
protected function doImport(OutputInterface $output, $fileName, $exec): bool
{
$success = true;

$returnValue = null;
$commandOutput = null;
$output->writeln(
Expand All @@ -207,7 +211,10 @@ protected function doImport(OutputInterface $output, $fileName, $exec)
exec($exec, $commandOutput, $returnValue);
if ($returnValue != 0) {
$output->writeln('<error>' . implode(PHP_EOL, $commandOutput) . '</error>');
$success = false;
}
$output->writeln('<info>Finished</info>');

return $success;
}
}

0 comments on commit a5f0b9d

Please sign in to comment.