Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Translator] Default value for 'sort' option in translation:update should be 'asc'#35486

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:4.4fromversgui:translation_update_cmd_sort
Jan 30, 2020

Conversation

@versgui
Copy link

QA
Branch?4.4
Bug fix?yes
New feature?no
Deprecations?no
Tickets
LicenseMIT
Doc PR

The value for 'sort' option forbin/console translation:update --sort is optional, but no default value is defined. So the list isn't sorted if no value is explicitly defined.
This MR brings a default value "asc" if no value is defined, so the list is correctly sorted.

Copy link
Member

@NyholmNyholm left a comment

Choose a reason for hiding this comment

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

Thank you for this PR.
I dont see where you set the default value. Am I missing something?


return1;
if ($input->hasOption('sort')) {
if ($sort =$input->getOption('sort')) {
Copy link
Member

Choose a reason for hiding this comment

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

Can this ever be false?

Copy link
Author

@versguiversguiJan 27, 2020
edited
Loading

Choose a reason for hiding this comment

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

getOption() returns null if no value has been defined.

Line 296: if thesort option has been defined, even if it has no value.
Lines 297-304: if a value has been defined, check that it's valid
Line 307: if the option has been explicitly set to 'desc', makes an rsort()
Line 398: we do a sort() in all other cases (including if there's no value defined)

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not defining the default value on the option definition instead of dealing with null and only allow asc and desc as strings and no empty value?

Copy link
Author

@versguiversguiJan 27, 2020
edited
Loading

Choose a reason for hiding this comment

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

I'm ok with this technicaly, but it would change the default behavior, where--sort=asc would be applied even if the--sort option is not specified. I didn't get into this because the goal is just to fix a bug, and I don't know if the default order responds to any particular logic.
There are actually three possible states: no sorting, asc and desc.

Copy link
Member

Choose a reason for hiding this comment

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

I would also setASC as the default value of the option instead of allowingnull which does not mean anything.

@versguiversgui changed the titleDefault value for 'sort' option in translation:update should be 'asc'[Translator] Default value for 'sort' option in translation:update should be 'asc'Jan 27, 2020

return1;
if ($input->hasOption('sort')) {
if ($sort =$input->getOption('sort')) {
Copy link
Member

Choose a reason for hiding this comment

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

I would also setASC as the default value of the option instead of allowingnull which does not mean anything.

@versgui
Copy link
Author

I made the modification: the command now returns the list with "sort=asc" by default.

Copy link
Member

@NyholmNyholm left a comment

Choose a reason for hiding this comment

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

Thank you.

Looking atif ($sort = $input->getOption('sort')), it is fine to keep the if statement. If someone calls with--sort=, we will be safe.

@fabpotfabpotforce-pushed thetranslation_update_cmd_sort branch from0b6a58c tofdb13c8CompareJanuary 30, 2020 16:24
@fabpot
Copy link
Member

Thank you@versgui.

fabpot added a commit that referenced this pull requestJan 30, 2020
…n:update should be 'asc' (versgui)This PR was squashed before being merged into the 4.4 branch (closes#35486).Discussion----------[Translator] Default value for 'sort' option in translation:update should be 'asc'| Q             | A| ------------- | ---| Branch?       | 4.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       || License       | MIT| Doc PR        |The value for 'sort' option for `bin/console translation:update --sort` is optional, but no default value is defined. So the list isn't sorted if no value is explicitly defined.This MR brings a default value "asc" if no value is defined, so the list is correctly sorted.Commits-------fdb13c8 [Translator] Default value for 'sort' option in translation:update should be 'asc'
@fabpotfabpot merged commitfdb13c8 intosymfony:4.4Jan 30, 2020
This was referencedJan 31, 2020
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@OskarStarkOskarStarkOskarStark left review comments

@fabpotfabpotfabpot approved these changes

@NyholmNyholmNyholm approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@versgui@fabpot@OskarStark@Nyholm@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp