summaryrefslogtreecommitdiff
path: root/modules/gallery
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery')
-rw-r--r--modules/gallery/libraries/MY_ORM.php20
-rw-r--r--modules/gallery/models/item.php3
-rw-r--r--modules/gallery/tests/Item_Model_Test.php1
3 files changed, 4 insertions, 20 deletions
diff --git a/modules/gallery/libraries/MY_ORM.php b/modules/gallery/libraries/MY_ORM.php
index 1bf5dd13..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($reload_all=true) {
- if ($reload_all) {
- 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/models/item.php b/modules/gallery/models/item.php
index 395ba52c..46b0304e 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -442,8 +442,9 @@ class Item_Model extends ORM_MPTT {
->where("right_ptr", "<", $this->right_ptr)
->execute();
}
+ $original = clone $this->original();
parent::save();
- module::event("item_updated", $this->original(), $this);
+ module::event("item_updated", $original, $this);
}
}
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);