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

Skip to content

[Console] Support ProgressBar::iterate() on empty array #52605

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

Merged
merged 1 commit into from
Nov 16, 2023

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Nov 15, 2023

Q A
Branch? 7.1
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #47244
License MIT

Alternative to #47259

Use $max = null to indicate that the value is unknown. This allows 0 to be displayed by directly setting the progress bar to 100%.

Zero is only supported for iterate(). When passed to the constructor or setMaxSteps, it means "unknown max".

Copy link
Member Author

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

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

We could deprecate passing 0 for unknown max, but that's not necessary to fix the reported issue.

I create a branch with the deprecation, that we can discuss for 7.1: 6.4...GromNaN:symfony:issue-47259-deprecate

@@ -195,7 +195,7 @@ public function getStartTime(): int

public function getMaxSteps(): int
{
return $this->max;
return $this->max ?? 0;
Copy link
Member Author

Choose a reason for hiding this comment

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

$this->max can be null, but keep returning 0 for backward compatibility.

@fabpot fabpot changed the base branch from 6.4 to 7.1 November 16, 2023 18:07
@fabpot fabpot modified the milestones: 6.4, 7.1 Nov 16, 2023
@fabpot
Copy link
Member

fabpot commented Nov 16, 2023

Merging in 7.1 as this is a behavior change.

@fabpot
Copy link
Member

fabpot commented Nov 16, 2023

Thank you @GromNaN.

@fabpot fabpot merged commit 4e944be into symfony:7.1 Nov 16, 2023
@GromNaN GromNaN deleted the issue-47259 branch November 16, 2023 18:11
@GromNaN GromNaN added Feature and removed Bug labels Nov 16, 2023
@fabpot fabpot mentioned this pull request May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ProgressBar] Empty iterable throws Exception on "maximum number of steps is not set"
4 participants