From f0a290fc7617f62e7e53bd4659f541a9c340ba1c Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 17 Jan 2010 13:29:36 -0800 Subject: If we call original() and there's no $original yet, then consider this to be the original. That should be safe because we're already guarding __set, __unset and save. --- modules/gallery/libraries/MY_ORM.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'modules/gallery/libraries/MY_ORM.php') diff --git a/modules/gallery/libraries/MY_ORM.php b/modules/gallery/libraries/MY_ORM.php index 56c776aa..8c0f084f 100644 --- a/modules/gallery/libraries/MY_ORM.php +++ b/modules/gallery/libraries/MY_ORM.php @@ -49,6 +49,10 @@ class ORM extends ORM_Core { } public function original() { + if (!isset($this->original)) { + $this->original = clone $this; + } + return $this->original; } } -- cgit v1.2.3 From f6c48d757c8f95249e58280e93c99aa4a6f217b1 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 20 Jan 2010 22:56:37 -0800 Subject: Delete MY_ORM::original(). We did not have proper containment to generate $original when we needed it, resulting in inconsistent behavior. --- modules/gallery/libraries/MY_ORM.php | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'modules/gallery/libraries/MY_ORM.php') diff --git a/modules/gallery/libraries/MY_ORM.php b/modules/gallery/libraries/MY_ORM.php index 8c0f084f..102b21f0 100644 --- a/modules/gallery/libraries/MY_ORM.php +++ b/modules/gallery/libraries/MY_ORM.php @@ -18,42 +18,9 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class ORM extends ORM_Core { - // Track the original value of this ORM so that we can look it up in ORM::original() - protected $original = null; - public function save() { model_cache::clear(); $result = parent::save(); - $this->original = clone $this; - return $result; - } - - public function __set($column, $value) { - if (!isset($this->original)) { - $this->original = clone $this; - } - - if ($value instanceof SafeString) { - $value = $value->unescaped(); - } - - return parent::__set($column, $value); - } - - public function __unset($column) { - if (!isset($this->original)) { - $this->original = clone $this; - } - - return parent::__unset($column); - } - - public function original() { - if (!isset($this->original)) { - $this->original = clone $this; - } - - return $this->original; } } -- cgit v1.2.3 From 949586c254f3b70a4b44828d1dee600cc6276a50 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 20 Jan 2010 23:28:29 -0800 Subject: Oops, bug in save() -- we weren't returning the saved value! --- modules/gallery/libraries/MY_ORM.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gallery/libraries/MY_ORM.php') diff --git a/modules/gallery/libraries/MY_ORM.php b/modules/gallery/libraries/MY_ORM.php index 102b21f0..a158d853 100644 --- a/modules/gallery/libraries/MY_ORM.php +++ b/modules/gallery/libraries/MY_ORM.php @@ -20,7 +20,7 @@ class ORM extends ORM_Core { public function save() { model_cache::clear(); - $result = parent::save(); + return parent::save(); } } -- cgit v1.2.3