Doctrine 1
  1. Doctrine 1
  2. DC-136

Table->find() does not reset the modified field list

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.0-ALPHA2
    • Fix Version/s: 1.2.0-ALPHA3
    • Component/s: None
    • Labels:
      None

      Description

      I think I can best explain what is happening with the following code:

      // Create some object in the database.
      $instance = new Model();
      $instance->field = "value 1";
      $instance->save();
      $id = $instance->id;
      
      $table = Doctrine::getTable('Model');
      
      // Load the object from the database.
      $instance_a = $table->find($id);
      
      // Modify a field. 
      $instance_a->field = "value 2";
      print $instance_a->field . "\n";     // prints "value 2";
      print_r($instance_a->getModified()); // prints "field"
      
      // Load the object again from the database, into a new variable.
      $instance_b = $table->find($id);
      
      // $instance_a and $instance_b now are the same object.
      // The data is fresh data from the database.
      print $instance_a->field . "\n"; // prints "value 1";
      print $instance_b->field . "\n"; // prints "value 1";
      
      // However, the modified field list was not reset.
      print_r($instance_a->getModified()); // prints "field"
      print_r($instance_b->getModified()); // prints "field"
      

      So the fresh record from the database is incorrectly marked as dirty. Main result is that this will trigger database activity when saving a model to the database, while no field data was actually changed.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Maurice Makaay
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: