Osclass icon indicating copy to clipboard operation
Osclass copied to clipboard

Unexpected error message "Price must be positive number." when editing an item with price greater than 2147.00

Open nikk0s opened this issue 2 years ago • 0 comments

Osclass 5.1.2 Unable to edit an item when price greater than 2147.00 ("Price must be positive number." error)

In some platforms (32 bits), also where PHP_INT_MAX=2147483647, the sign test (int)$aItem['price'] < 0 may produce unexpected result if item price greater than 2147.00 and also ItemActions->validateCommonInput() method will failed (since price is multiplied by 1,000,000 before validation and store in database)

To Reproduce Steps to reproduce the behavior:

  1. Edit an item
  2. Set a price greater than 2147.00
  3. Save -> save failed with error: "Price must be positive number."

Expected behavior Save successfull

Bug Fix Replace line 456 in ItemActions.php: $flash_error .= (($aItem['price'] !== null && (int)$aItem['price'] < 0) by: $flash_error .= (($aItem['price'] !== null && (float)$aItem['price'] < 0)

Regards

nikk0s avatar Feb 09 '22 00:02 nikk0s