Browse Source

Divide by zero prevention in console progress bar

close #10541
tags/2.0.7
youmad 9 years ago committed by Carsten Brandt
parent
commit
77b0d30bf8
  1. 1
      framework/CHANGELOG.md
  2. 2
      framework/helpers/BaseConsole.php

1
framework/CHANGELOG.md

@ -48,6 +48,7 @@ Yii Framework 2 Change Log
- Bug #10372: Fixed console controller including DI arguments in help (sammousa) - Bug #10372: Fixed console controller including DI arguments in help (sammousa)
- Bug #10385: Fixed `yii\validators\CaptchaValidator` passed incorrect hashKey to JS validator when `captchaAction` begins with `/` (silverfire) - Bug #10385: Fixed `yii\validators\CaptchaValidator` passed incorrect hashKey to JS validator when `captchaAction` begins with `/` (silverfire)
- Bug #10467: Fixed `yii\di\Instance::ensure()` to work with minimum settings (LAV45) - Bug #10467: Fixed `yii\di\Instance::ensure()` to work with minimum settings (LAV45)
- Bug #10541: Fixed division by zero issue in `Console` helper progress bar (youmad)
- Bug: Fixed generation of canonical URLs for `ViewAction` pages (samdark) - Bug: Fixed generation of canonical URLs for `ViewAction` pages (samdark)
- Bug: Fixed `mb_*` functions calls to use `UTF-8` or `Yii::$app->charset` (silverfire) - Bug: Fixed `mb_*` functions calls to use `UTF-8` or `Yii::$app->charset` (silverfire)
- Enh #3506: Added `yii\validators\IpValidator` to perform validation of IP addresses and subnets (SilverFire, samdark) - Enh #3506: Added `yii\validators\IpValidator` to perform validation of IP addresses and subnets (SilverFire, samdark)

2
framework/helpers/BaseConsole.php

@ -954,7 +954,7 @@ class BaseConsole
self::$_progressEtaLastUpdate = time(); self::$_progressEtaLastUpdate = time();
} elseif ($done < $total) { } elseif ($done < $total) {
// update ETA once per second to avoid flapping // update ETA once per second to avoid flapping
if (time() - self::$_progressEtaLastUpdate > 1) { if (time() - self::$_progressEtaLastUpdate > 1 && $done > self::$_progressEtaLastDone) {
$rate = (time() - (self::$_progressEtaLastUpdate ?: self::$_progressStart)) / ($done - self::$_progressEtaLastDone); $rate = (time() - (self::$_progressEtaLastUpdate ?: self::$_progressStart)) / ($done - self::$_progressEtaLastDone);
self::$_progressEta = $rate * ($total - $done); self::$_progressEta = $rate * ($total - $done);
self::$_progressEtaLastUpdate = time(); self::$_progressEtaLastUpdate = time();

Loading…
Cancel
Save