Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
ostrolucky merged 7 commits into
doctrine:2.8.xfrom
alexander-schranz:patch-1
Feb 1, 2021
Merged

Fix --complete flag in orm:ensure-production-settings command#8426
ostrolucky merged 7 commits into
doctrine:2.8.xfrom
alexander-schranz:patch-1

Conversation

@alexander-schranz
Copy link
Copy Markdown
Contributor

$input->getOption('complete') returns false and not null if not set.

$em->getConfiguration()->ensureProductionSettings();

if ($input->getOption('complete') !== null) {
if (!$input->getOption('complete')) {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@SenseException
Copy link
Copy Markdown
Member

@doctrine/team-orm Do we need OrmFunctionalTestCase in the test class?

@ostrolucky
Copy link
Copy Markdown
Member

I don't think so.

@alexander-schranz
Copy link
Copy Markdown
Contributor Author

Change to the DoctrineTestCase

@alexander-schranz
Copy link
Copy Markdown
Contributor Author

Anything I can do to get this merged?

@SenseException
Copy link
Copy Markdown
Member

SenseException commented Feb 1, 2021

Currently not. This will be handled by another reviewer after a second pair of eyes take a look at this PR.

@ostrolucky ostrolucky added this to the 2.8.2 milestone Feb 1, 2021
@ostrolucky ostrolucky changed the title Fix ensure production settings command without connection Fix --complete flag in orm:ensure-production-settings command Feb 1, 2021
@ostrolucky ostrolucky merged commit f92c3db into doctrine:2.8.x Feb 1, 2021
@alexander-schranz alexander-schranz deleted the patch-1 branch February 2, 2021 06:18
@alexander-schranz
Copy link
Copy Markdown
Contributor Author

@SenseException @ostrolucky thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants