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

Skip to content

ProgressBar division by 0 when setting $startAt #59067

Closed
@Rindula

Description

@Rindula

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions