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

Skip to content

ProgressBar division by 0 when setting $startAt #59067

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

Closed
Rindula opened this issue Dec 2, 2024 · 0 comments
Closed

ProgressBar division by 0 when setting $startAt #59067

Rindula opened this issue Dec 2, 2024 · 0 comments

Comments

@Rindula
Copy link
Contributor

Rindula commented Dec 2, 2024

Symfony version(s) affected

7.2.0

Description

When using the Progressbar and having a custom format using the %remaining% part, the Progressbar will error with

In ProgressBar.php line 236:

  Division by zero

How to reproduce

  1. Create a console command using the Progressbar
  2. Initiate a new Progressbar Object $pb = new ProgressBar($io, $total);
  3. Start the Progressbar with $pb->start($total, $skip); where $total > $skip > 0

Possible Solution

Change in ProgressBar.php line 232 - 234 from

if (!$this->step) {
    return 0;
}

to

if (0 === $this->step || $this->step === $this->startingStep) {
    return 0;
}

as in getEstimated()

Additional Context

No response

@Rindula Rindula added the Bug label Dec 2, 2024
Rindula added a commit to Rindula/symfony that referenced this issue Dec 2, 2024
@xabbuh xabbuh added the Console label Dec 2, 2024
Rindula added a commit to Rindula/symfony that referenced this issue Dec 2, 2024
fabpot added a commit that referenced this issue Dec 6, 2024
This PR was squashed before being merged into the 6.4 branch.

Discussion
----------

[Console] Fix division by 0 error

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Issues        | Fix #59067 <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->
| License       | MIT

<!--
Replace this notice by a description of your feature/bugfix.
This will help reviewers and should be a good start for the documentation.

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against the latest branch.
 - For new features, provide some code snippets to help understand usage.
 - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
 - Never break backward compatibility (see https://symfony.com/bc).
-->

Commits
-------

ee400b0 [Console] Fix division by 0 error
@fabpot fabpot closed this as completed Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants