-
Bug
-
Resolution: Fixed
-
Minor
-
3.11.7, 4.0.1
-
MOODLE_311_STABLE, MOODLE_400_STABLE
-
MOODLE_311_STABLE, MOODLE_400_STABLE
-
MDL-74886-master -
The duration config type takes two values, a value and a unit.
The unit is generally always something that can be cast to int.
However, the value, which is provided by the user - might not be. If no value is entered, or a value which does not cast to an int - then php performs a string*string operation instead of int*int.
For php before php8 - this simply resulted in a Warning - and the default validation was able to confirm it wasn't set correctly and prompt the user for a better value.
From php8 however, string*string opts now raise a TypeError exception - so the user instead sees "Exception - Unsupported operand types: string * string".
The fix for this is rather trivial - rather casting the result of u * v to an int, cast each value separately to an int before multiplying them.