From 02f30b91bf8f68118a578de2194e66a7a16a291a Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 15 Jan 2011 14:20:26 -0800 Subject: Follow on to 966dee8628293f78fbf9431281709ceba011d3c2 for #1586 -- don't try to update the tag item count if we didn't change any items with this change (ie: a tag rename). In that case, we haven't loaded the related items so we don't have any idea what the count is going to be. --- modules/tag/models/tag.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'modules/tag') diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php index 25df87e0..2b73b5be 100644 --- a/modules/tag/models/tag.php +++ b/modules/tag/models/tag.php @@ -78,12 +78,14 @@ class Tag_Model_Core extends ORM { $related_item_ids[$row->item_id] = 1; } - $added = array_diff($this->changed_relations["items"], $this->object_relations["items"]); - $removed = array_diff($this->object_relations["items"], $this->changed_relations["items"]); - if (isset($this->changed_relations["items"])) { - $changed = array_merge($added, $removed); + if (isset($this->object_relations["items"])) { + $added = array_diff($this->changed_relations["items"], $this->object_relations["items"]); + $removed = array_diff($this->object_relations["items"], $this->changed_relations["items"]); + if (isset($this->changed_relations["items"])) { + $changed = array_merge($added, $removed); + } + $this->count = count($this->object_relations["items"]) + count($added) - count($removed); } - $this->count = count($this->object_relations["items"]) + count($added) - count($removed); $result = parent::save(); -- cgit v1.2.3