Browse files

ORM::$_original_values will not be a snapshot of ORM::$_object at loa…

…d time (refs #3691)
  • Loading branch information...
1 parent 2ded504 commit 88a769acd909de96ef7f8b9632d0853d078fa1c0 @Zeelot Zeelot committed Jul 1, 2011
Showing with 10 additions and 14 deletions.
  1. +10 −14 classes/kohana/orm.php
View
24 classes/kohana/orm.php
@@ -469,12 +469,6 @@ public function __isset($column)
*/
public function __unset($column)
{
- if ($this->loaded() AND ! array_key_exists($column, $this->_original_values))
- {
- // Store the original for validation purposes
- $this->_original_values[$column] = $this->_object[$column];
- }
-
unset($this->_object[$column], $this->_changed[$column], $this->_related[$column]);
}
@@ -663,12 +657,6 @@ public function set($column, $value)
// See if the data really changed
if ($value !== $this->_object[$column])
{
- if ( ! array_key_exists($column, $this->_original_values))
- {
- // Store the original for validation purposes
- $this->_original_values[$column] = $this->_object[$column];
- }
-
$this->_object[$column] = $value;
// Data has changed
@@ -1054,6 +1042,12 @@ protected function _load_values(array $values)
}
}
+ if ($this->_loaded)
+ {
+ // Store the object in its original state
+ $this->_original_values = $this->_object;
+ }
+
return $this;
}
@@ -1237,7 +1231,8 @@ public function create(Validation $validation = NULL)
$this->_loaded = $this->_saved = TRUE;
// All changes have been saved
- $this->_changed = $this->_original_values = array();
+ $this->_changed = array();
+ $this->_original_values = $this->_object;;
return $this;
}
@@ -1301,7 +1296,8 @@ public function update(Validation $validation = NULL)
$this->_saved = TRUE;
// All changes have been saved
- $this->_changed = $this->_original_values = array();
+ $this->_changed = array();
+ $this->_original_values = $this->_object;
return $this;
}

0 comments on commit 88a769a

Please sign in to comment.