MDL-70854 core: Revert removal of conditions to update progress

The conditions for updating the progress in the progress bar were
mistakenly removed. We need to revert these to ensure proper operation
of the progress bar.
This commit is contained in:
Jun Pataleta
2024-07-24 10:48:00 +08:00
parent 42aca7aaf7
commit 467fa44233
+9 -2
View File
@@ -161,8 +161,15 @@ class progress_bar implements renderable, templatable {
'argument to the constructor) before you try updating the progress bar.');
}
// No significant change, no need to update anything.
if (round($this->percent, 2) === round($percent, 2)) {
$estimate = $this->estimate($percent);
if ($estimate === null) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf
// Always do the first and last updates.
} else if ($estimate == 0) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf
// Always do the last updates.
} else if ($this->lastupdate + 20 < time()) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf
// We must update otherwise browser would time out.
} else if (round($this->percent, 2) === round($percent, 2)) {
return;
}