cubecart / v6

CubeCart Version 6
https://cubecart.com
72 stars 59 forks source link

Code Check: Product Maximum Quantity #3492

Closed bhsmither closed 5 months ago

bhsmither commented 6 months ago

Please examine your database at the CubeCart_inventory. maximum_quantity column.

The default value is an allowed null, but the value may actually be a zero. (It is in my database.)

When blanking the "Maximum Quantity Purchase" text entry field and Saving the form, the POST['maximum_quantity'] does have a zero-length-string value. (So does POST['live_from'].)

The database has INT as the data type for this column. When issuing an UPDATE query, the database issues:

Warning (1366) "Incorrect integer value: '' for column `CubeCart_inventory`.`live_from` at row 1"
Warning (1366) "Incorrect integer value: '' for column `CubeCart_inventory`.`maximum_quantity` at row 1"

I believe that the database engine then refuses to actually update those fields with the default value, and instead uses the equivalent integer value (being zero).

(I wonder if there is a database setting for this.)

bhsmither commented 6 months ago

On this page: https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html, near the bottom:

For example, in non-strict SQL mode, inserting the string 'abc' into an integer column results in conversion of the value to 0 and a warning...