Author Topic: DataObject->validateMaxValueOf($column, $max) bug  (Read 2552 times)

wal5hy

  • Newbie
  • *
  • Posts: 3
    • View Profile
DataObject->validateMaxValueOf($column, $max) bug
« on: March 02, 2010, 11:29:20 am »
I'm pretty sure that there is a small bug in the DataObject->validateMaxValueOf($column, $max) function. (line 1108 of DataObject.class.php in environment/classes/dataaccess)

The problem is that the function does not work when validating ints and floats (however it does work with string), the reason is that in the code the wrong variables are being compared

line 1114 onwards reads:
       // Get value...
       $value = $this->getColumnValue($column);
       
       // Integer and float...
       if(is_int($value) || is_float($column)) {
         return $column <= $max;
       }

line 1118 should read:
       if(is_int($value) || is_float($value)) {
         return $value <= $max; 
       }
not:
       if(is_int($value) || is_float($column)) {
         return $column <= $max;
       }

This same error (comparing a column name to an integer) is repeated on lines 1126, and again in the function validateMinValueOf lines 1149 and line 1157

hope this helps

bug applies to version 1.6.2
« Last Edit: March 02, 2010, 11:32:47 am by wal5hy »

apmuthu

  • Freshman
  • *
  • Posts: 28
    • View Profile
Re: DataObject->validateMaxValueOf($column, $max) bug
« Reply #1 on: March 07, 2010, 08:10:49 am »
Yes you are right. The current v1.8 of the said file in the CVS has the error only in line 1115:
Code: [Select]
    if(is_int($value) || is_float($column)) {
should be
Code: [Select]
    if(is_int($value) || is_float($value)) {
Hope the admin will update the repository. The previous 2 diffs are merely adding of a blank line and changing of version number!

ignacio

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
Re: DataObject->validateMaxValueOf($column, $max) bug
« Reply #2 on: March 10, 2010, 05:34:56 pm »
Thank you both. This has been fixed for 1.7