htmlform: fix min/max validations on empty input in int/float fields

Int and float fields that are optional cannot currently specify the min
attribute. An unfilled value fails the validation because in PHP 8 any
number is greater than the empty string.

(For comparing numbers with non-numeric strings, the number is first
converted to a string and then compared. In PHP 7, the string was
converted to a number instead.)

Bug: T397883
Bug: T397643
Change-Id: I37be84554708e17eee27a7e599815891787e95bf
(cherry picked from commit 8e7ae749c0870e8133d083ac4125280c11a12ea6)
This commit is contained in:
Siddharth VP 2025-06-28 15:26:56 +05:30 committed by Umherirrender
parent db6013aa6c
commit 4fb27b070e

View file

@ -20,6 +20,9 @@ class HTMLFloatField extends HTMLTextField {
}
$value = trim( $value ?? '' );
if ( $value === '' ) {
return true;
}
# https://www.w3.org/TR/html5/infrastructure.html#floating-point-numbers
# with the addition that a leading '+' sign is ok.