From aa5ac2cd3ae790690cb1154a81ffc06e45fd1bfb Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 30 Mar 2013 21:45:24 +0400 Subject: [PATCH] do not create duplicate archived feeds on unsubscribe, file entries into already existing archive entry --- classes/pref/feeds.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 1ec0b7b5..7895a039 100644 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1702,18 +1702,27 @@ class Pref_Feeds extends Handler_Protected { /* prepare feed if necessary */ + $result = db_query($link, "SELECT feed_url FROM ttrss_feeds WHERE id = $id + AND owner_uid = $owner_uid"); + + $feed_url = db_escape_string($link, db_fetch_result($result, 0, "feed_url")); + $result = db_query($link, "SELECT id FROM ttrss_archived_feeds - WHERE id = '$id'"); + WHERE feed_url = '$feed_url' AND owner_uid = $owner_uid"); if (db_num_rows($result) == 0) { db_query($link, "INSERT INTO ttrss_archived_feeds (id, owner_uid, title, feed_url, site_url) SELECT id, owner_uid, title, feed_url, site_url from ttrss_feeds - WHERE id = '$id'"); + WHERE id = '$id'"); + + $archive_id = $id; + } else { + $archive_id = db_fetch_result($result, 0, "id"); } db_query($link, "UPDATE ttrss_user_entries SET feed_id = NULL, - orig_feed_id = '$id' WHERE feed_id = '$id' AND + orig_feed_id = '$archive_id' WHERE feed_id = '$id' AND marked = true AND owner_uid = $owner_uid"); /* Remove access key for the feed */ -- 2.39.5