From 26c3700dc513e295b3fd5c9c6b88c225639d5cc6 Mon Sep 17 00:00:00 2001 From: Michael J Rubinsky Date: Wed, 16 Sep 2015 11:37:42 -0400 Subject: [PATCH] Only increment counters if we actually tagged the item. Related to Bug: 14112 --- content/lib/Tagger.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/content/lib/Tagger.php b/content/lib/Tagger.php index f0952bb718d..69d5cbb4889 100644 --- a/content/lib/Tagger.php +++ b/content/lib/Tagger.php @@ -117,16 +117,16 @@ public function tag($userId, $objectId, $tags, Horde_Date $created = null) } catch (Horde_Db_Exception $e) { throw new Content_Exception($e); } - } - // increment tag stats - if (!$this->_db->update('UPDATE ' . $this->_t('tag_stats') . ' SET count = count + 1 WHERE tag_id = ' . (int)$tagId)) { - $this->_db->insert('INSERT INTO ' . $this->_t('tag_stats') . ' (tag_id, count) VALUES (' . (int)$tagId . ', 1)', null, null, 'tag_id', $tagId); - } + // increment tag stats + if (!$this->_db->update('UPDATE ' . $this->_t('tag_stats') . ' SET count = count + 1 WHERE tag_id = ' . (int)$tagId)) { + $this->_db->insert('INSERT INTO ' . $this->_t('tag_stats') . ' (tag_id, count) VALUES (' . (int)$tagId . ', 1)', null, null, 'tag_id', $tagId); + } - // increment user-tag stats - if (!$this->_db->update('UPDATE ' . $this->_t('user_tag_stats') . ' SET count = count + 1 WHERE user_id = ' . (int)$userId . ' AND tag_id = ' . (int)$tagId)) { - $this->_db->insert('INSERT INTO ' . $this->_t('user_tag_stats') . ' (user_id, tag_id, count) VALUES (' . (int)$userId . ', ' . (int)$tagId . ', 1)'); + // increment user-tag stats + if (!$this->_db->update('UPDATE ' . $this->_t('user_tag_stats') . ' SET count = count + 1 WHERE user_id = ' . (int)$userId . ' AND tag_id = ' . (int)$tagId)) { + $this->_db->insert('INSERT INTO ' . $this->_t('user_tag_stats') . ' (user_id, tag_id, count) VALUES (' . (int)$userId . ', ' . (int)$tagId . ', 1)'); + } } } }