MDL-78544 forms: fix string to number comparison bug in duration element

Prior to PHP 8, 0 == "", but now no more. We should use empty instead.
See: https://www.php.net/manual/en/migration80.incompatible.php
This commit is contained in:
Jake Dallimore
2023-06-22 11:01:17 +08:00
parent 64b701190d
commit 331f47a4f3
+1 -1
View File
@@ -157,7 +157,7 @@ class MoodleQuickForm_duration extends MoodleQuickForm_group {
* @return array associative array ($number => $unit)
*/
public function seconds_to_unit($seconds) {
if ($seconds == 0) {
if (empty($seconds)) {
return [0, $this->_options['defaultunit']];
}
foreach ($this->get_units_used() as $unit => $notused) {