diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-01-15 23:53:43 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-01-15 23:53:43 -0800 |
commit | 00c73a4b072d2ad4e45323234b847da4f69d99a3 (patch) | |
tree | f0ae99159b46ca0531b5a38d3076635e3da3bffe | |
parent | 99073c3e201c0d2770909781ad0afefdd9d44931 (diff) |
Revert "Fix for ticket #978. Don't reset the original property as part of the save processing, because that will overwrite the original values with all the new values. The problem with the original approach is that when changed event handlers used ->original(), it had already been reset as part of the save processing. Went back and forth on either leaving this alone and forcing callers to save the original prior to calling the save function, but there were a few event handlers that used ->original(). This seemed the easier change. So to reset the original you need to call reload() or clear(). There is now an optional parameter on the reload to only reload the original."
This reverts commit daeaca110d16128040c86727c65df225e957f7c6.
-rw-r--r-- | modules/gallery/libraries/MY_ORM.php | 20 | ||||
-rw-r--r-- | modules/gallery/tests/Item_Model_Test.php | 1 |
2 files changed, 2 insertions, 19 deletions
diff --git a/modules/gallery/libraries/MY_ORM.php b/modules/gallery/libraries/MY_ORM.php index 95fa9006..56c776aa 100644 --- a/modules/gallery/libraries/MY_ORM.php +++ b/modules/gallery/libraries/MY_ORM.php @@ -19,11 +19,12 @@ */ class ORM extends ORM_Core { // Track the original value of this ORM so that we can look it up in ORM::original() - protected $original; + protected $original = null; public function save() { model_cache::clear(); $result = parent::save(); + $this->original = clone $this; return $result; } @@ -47,24 +48,7 @@ class ORM extends ORM_Core { return parent::__unset($column); } - public function reload($original_only=false) { - if (!$original_only) { - parent::reload(); - } - $this->original = clone $this; - return $this; - } - - public function clear() { - parent::clear(); - $this->original = clone $this; - return $this; - } - public function original() { - if (!isset($this->original)) { - $this->original = clone $this; - } return $this->original; } } diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php index c0ac4436..bf5fca1a 100644 --- a/modules/gallery/tests/Item_Model_Test.php +++ b/modules/gallery/tests/Item_Model_Test.php @@ -166,7 +166,6 @@ class Item_Model_Test extends Unit_Test_Case { $item = self::_create_random_item(); $item->title = "ORIGINAL_VALUE"; $item->save(); - $item->reload(false); $item->title = "NEW_VALUE"; $this->assert_same("ORIGINAL_VALUE", $item->original()->title); |