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 10:54:46 +08:00
parent 1b1a15a308
commit 60b086635c
No known key found for this signature in database

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) {