Uploaded image for project: 'Doctrine 1'
  1. Doctrine 1
  2. DC-814

protected method _isValueModified returns wrong result

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.2
    • Fix Version/s: None
    • Component/s: Record
    • Labels:
      None
    • Environment:
      Apache/2.2.15 (Win64) PHP/5.3.2

      Description

          protected function _isValueModified($type, $old, $new)
          {
              if ($new instanceof Doctrine_Expression) {
                  return true;
              }
      
              if ($type == 'boolean' && (is_bool($old) || is_numeric($old)) && (is_bool($new) || is_numeric($new)) && $old == $new) {
                  return false;
              } else if (in_array($type, array('decimal', 'float')) && is_numeric($old) && is_numeric($new)) {
                  return $old * 100 != $new * 100;
              } else if (in_array($type, array('integer', 'int')) && is_numeric($old) && is_numeric($new)) {
                  // getType($old) in many cases is always 'string' so using operator '!=='  is make no sense 
                  // the only needed condition is already checked: i mean 'is_numeric'
                  return $old !== $new;
              } else if ($type == 'timestamp' || $type == 'date') {
                  $oldStrToTime = strtotime($old);
                  $newStrToTime = strtotime($new);
                  if ($oldStrToTime && $newStrToTime) {
                      // the same here: it's make no sense to using '!==' - first and second variable are the same type 
                      return $oldStrToTime !== $newStrToTime;
                  } else {
                      return $old !== $new;
                  }
              } else {
                  return $old !== $new;
              }
          }
      

        Activity

        Hide
        mstrzele Michał Strzelecki added a comment - - edited

        Using operator '!==' is make no sense. The result is wrong after that comparition.
        The implication of that is wrong state of the record if it is id of relation hydrate after joins.

        Show
        mstrzele Michał Strzelecki added a comment - - edited Using operator '!==' is make no sense. The result is wrong after that comparition. The implication of that is wrong state of the record if it is id of relation hydrate after joins.

          People

          • Assignee:
            jwage Jonathan H. Wage
            Reporter:
            mstrzele Michał Strzelecki
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: