Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Values introuced in 'min qty' and 'max qty' are not processed. So for example if you introduce a string instead of an Integer, you get a nice database fatal error since it is expecting an integer not a string.
Comment | File | Size | Author |
---|---|---|---|
#8 | max_min_qty_validation-2147681-8.patch | 1.27 KB | eldrupalista |
#1 | max_min_qty_validation-2147681-1.patch | 1.27 KB | eldrupalista |
Comments
Comment #1
eldrupalista CreditAttribution: eldrupalista commentedCreated a patch that checks that 'max_qty' and 'min_qty' fields are integer numbers and greater than -1 or 0 respectively.
Comment #2
eldrupalista CreditAttribution: eldrupalista commentedComment #3
pcambraNice catch, but we'd rather use is_integer instead of a regexp http://us3.php.net/manual/en/function.is-int.php
Comment #4
pcambraThis is definitely not a major bug :P
Comment #5
eldrupalista CreditAttribution: eldrupalista commentedWe cannot use is_int for checking from an input variable since it is always a string. We cannot use either is_numeric in this case because something like 1.34 would be OK.
Comment #6
pcambraGood catch with the decimals, instead of 0-9 we could use d in the regexp...
What about http://us2.php.net/manual/en/function.ctype-digit.php
Comment #7
eldrupalista CreditAttribution: eldrupalista commentedctype_digit function seems to work well for detecting natural numbers, but does not work for detecting the '-1' that is possible in max_qty.
Anyway, I can modify the preg_check for usgin that function instead.
Comment #8
eldrupalista CreditAttribution: eldrupalista commentedComment #9
rszrama CreditAttribution: rszrama commentedI retooled the logic of your patch and generally updated the error messages that get displayed. There was no reason they shouldn't have been specific to the actual form fields that generated them. Should all be fixed now.