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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

eldrupalista’s picture

Created a patch that checks that 'max_qty' and 'min_qty' fields are integer numbers and greater than -1 or 0 respectively.

eldrupalista’s picture

Status: Active » Needs review
pcambra’s picture

Nice catch, but we'd rather use is_integer instead of a regexp http://us3.php.net/manual/en/function.is-int.php

pcambra’s picture

Priority: Major » Normal

This is definitely not a major bug :P

eldrupalista’s picture

We 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.

pcambra’s picture

Good 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

eldrupalista’s picture

ctype_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.

eldrupalista’s picture

rszrama’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Needs review » Fixed

I 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.

  • rszrama committed 69815db on 7.x-1.x
    Issue #2147681 by rszrama, agviu: improve widget validation and error...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.