diff --git a/classes/article.php b/classes/article.php index b600adff2..f6a4462d6 100755 --- a/classes/article.php +++ b/classes/article.php @@ -179,7 +179,7 @@ class Article extends Handler_Protected { print ""; @@ -232,19 +232,24 @@ class Article extends Handler_Protected { $int_id = $row['int_id']; - $sth = $this->pdo->prepare("DELETE FROM ttrss_tags WHERE + $dsth = $this->pdo->prepare("DELETE FROM ttrss_tags WHERE post_int_id = ? AND owner_uid = ?"); - $sth->execute([$int_id, $_SESSION['uid']]); + $dsth->execute([$int_id, $_SESSION['uid']]); + + $csth = $this->pdo->prepare("SELECT post_int_id FROM ttrss_tags + WHERE post_int_id = ? AND owner_uid = ? AND tag_name = ?"); + + $usth = $this->pdo->prepare("INSERT INTO ttrss_tags + (post_int_id, owner_uid, tag_name) + VALUES (?, ?, ?)"); $tags = FeedItem_Common::normalize_categories($tags); foreach ($tags as $tag) { - if ($tag != '') { - $sth = $this->pdo->prepare("INSERT INTO ttrss_tags - (post_int_id, owner_uid, tag_name) - VALUES (?, ?, ?)"); + $csth->execute([$int_id, $_SESSION['uid'], $tag]); - $sth->execute([$int_id, $_SESSION['uid'], $tag]); + if (!$csth->fetch()) { + $usth->execute([$int_id, $_SESSION['uid'], $tag]); } array_push($tags_to_cache, $tag); diff --git a/classes/feeditem/common.php b/classes/feeditem/common.php index f208f4a48..1e9d62228 100755 --- a/classes/feeditem/common.php +++ b/classes/feeditem/common.php @@ -189,6 +189,9 @@ abstract class FeedItem_Common extends FeedItem { return $cat; }, $tmp); + // remove empty values + $tmp = array_filter($tmp, 'strlen'); + asort($tmp); return array_unique($tmp);