diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-01-16 00:13:28 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-01-16 00:13:28 -0800 |
commit | dcf4b5e71ae8a097f133a06485d60c5fb3400824 (patch) | |
tree | 2c1e6d81d91238fa636c4dd4949ccd2bf6856c1b | |
parent | 9f03d36d6ee5358b3081f64fc7ef0b0ae42d97db (diff) |
Don't pass MY_ORM::original() to update event handlers, since after
parent::save() it'll be reset. Clone it first.
This is an alternate fix for #978.
-rw-r--r-- | modules/comment/models/comment.php | 4 | ||||
-rw-r--r-- | modules/gallery/models/item.php | 4 | ||||
-rw-r--r-- | modules/user/models/group.php | 4 | ||||
-rw-r--r-- | modules/user/models/user.php | 4 |
4 files changed, 12 insertions, 4 deletions
diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php index 59b85233..e0b82039 100644 --- a/modules/comment/models/comment.php +++ b/modules/comment/models/comment.php @@ -65,12 +65,14 @@ class Comment_Model extends ORM { } } $visible_change = $this->original()->state == "published" || $this->state == "published"; + + $original = clone $this->original(); parent::save(); if (isset($created)) { module::event("comment_created", $this); } else { - module::event("comment_updated", $this->original(), $this); + module::event("comment_updated", $original, $this); } // We only notify on the related items if we're making a visible change. diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index 4a3d26e9..6851e1a3 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -416,9 +416,11 @@ class Item_Model extends ORM_MPTT { $send_event = 1; } } + + $original = clone $this->original(); parent::save(); if (isset($send_event)) { - module::event("item_updated", $this->original(), $this); + module::event("item_updated", $original, $this); } return $this; } diff --git a/modules/user/models/group.php b/modules/user/models/group.php index 515788a3..10f6f4b3 100644 --- a/modules/user/models/group.php +++ b/modules/user/models/group.php @@ -41,11 +41,13 @@ class Group_Model extends ORM implements Group_Definition { if (!$this->loaded()) { $created = 1; } + + $original = clone $this->original(); parent::save(); if (isset($created)) { module::event("group_created", $this); } else { - module::event("group_updated", $this->original(), $this); + module::event("group_updated", $original, $this); } return $this; } diff --git a/modules/user/models/user.php b/modules/user/models/user.php index 7d5bf413..edba2a2c 100644 --- a/modules/user/models/user.php +++ b/modules/user/models/user.php @@ -69,11 +69,13 @@ class User_Model extends ORM implements User_Definition { if (!$this->loaded()) { $created = 1; } + + $original = clone $this->original(); parent::save(); if (isset($created)) { module::event("user_created", $this); } else { - module::event("user_updated", $this->original(), $this); + module::event("user_updated", $original, $this); } return $this; } |