]> git.wh0rd.org Git - tt-rss.git/commitdiff
add ccache_cleanup(), invoke on login
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 5 Aug 2011 10:16:06 +0000 (14:16 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 5 Aug 2011 10:16:06 +0000 (14:16 +0400)
functions.php

index 7cd509ae710f43e20cdb89150d4de5bbfd4cccc7..0c58196567f0892537862347d6e49f128bc6dc85 100644 (file)
                                        setcookie("ttrss_lang", $_SESSION["language"],
                                                time() + SESSION_COOKIE_LIFETIME);
                                }
+
+                               // try to remove possible duplicates from feed counter cache
+                               ccache_cleanup($link, $_SESSION["uid"]);
                        }
 
                } else {
                return $unread;
        }
 
+       function ccache_cleanup($link, $owner_uid) {
+
+               db_query($link, "DELETE FROM ttrss_counters_cache AS c1 WHERE
+                       (SELECT count(*) FROM ttrss_counters_cache AS c2
+                               WHERE c1.feed_id = c2.feed_id AND c2.owner_uid = c1.owner_uid) > 1
+                               AND owner_uid = '$owner_uid'");
+
+               db_query($link, "DELETE FROM ttrss_cat_counters_cache AS c1 WHERE
+                       (SELECT count(*) FROM ttrss_cat_counters_cache AS c2
+                               WHERE c1.feed_id = c2.feed_id AND c2.owner_uid = c1.owner_uid) > 1
+                                       AND owner_uid = '$owner_uid'");
+       }
+
        function label_find_id($link, $label, $owner_uid) {
                $result = db_query($link,
                        "SELECT id FROM ttrss_labels2 WHERE caption = '$label'