Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix --complete flag in orm:ensure-production-settings command #8426

Merged
merged 7 commits into from
Feb 1, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
try {
$em->getConfiguration()->ensureProductionSettings();

if ($input->getOption('complete') !== null) {
if (!$input->getOption('complete')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current symfony returns false not sure if null was returned in older version so I did switch to using ! instead for checking for false or null.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a default value that can be set in addOption. Without an explicit value it is null.

https://github.com/symfony/console/blob/5.x/Command/Command.php#L400

It seems to be the same in 4.0 and 3.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like its not possible to set a default value for InputOption::VALUE_NONE: https://github.com/symfony/console/blob/356c70659d6b48595f9f275cd7c4de0d5544c49c/Input/InputOption.php#L168

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I could go with:

$input->getOption('complete') === true
$input->getOption('complete') !== false

or the current version.

The value of the input is set here to true:
https://github.com/symfony/console/blob/356c70659d6b48595f9f275cd7c4de0d5544c49c/Input/ArgvInput.php#L248

And default value to false:

https://github.com/symfony/console/blob/356c70659d6b48595f9f275cd7c4de0d5544c49c/Input/InputOption.php#L182

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's a boolean then your current syntax should fit. You currently let it step into the if-block when the value is false. It also looks like there are no tests yet that covers this class. Can you please create one that covers your changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SenseException created the missing test class hope it matches how tests are created in this repository.

$em->getConnection()->connect();
}
} catch (Throwable $e) {
Expand Down