]> git.wh0rd.org Git - tt-rss.git/commitdiff
properly calculate ccache changes to child feeds when processing category
authorAndrew Dolgov <fox@bah.spb.su>
Sat, 17 Jan 2009 12:19:18 +0000 (13:19 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sat, 17 Jan 2009 12:19:18 +0000 (13:19 +0100)
functions.php

index 8c11ed0d98ef23c1de9e3040b797da9737efcd89..9072b981b1a3c66563370bad4ca98e7206566b09 100644 (file)
 
        }
 
-       function ccache_update($link, $feed_id, $owner_uid, $is_cat = false) {
+       function ccache_update($link, $feed_id, $owner_uid, $is_cat = false, 
+                       $direct_only = false) {
 
                if (!$is_cat) {
                        $table = "ttrss_counters_cache";
                                
                }
 
-               if ($feed_id > 0) {
+               if ($feed_id > 0 && !$direct_only) {
 
                        if (!$is_cat) {
 
                                while ($line = db_fetch_assoc($result)) {
                                        ccache_update($link, $line["feed_id"], $owner_uid);
                                }
+                       } else {
+
+                               if ($feed_id == 0) {
+                                       $cat_qpart = "cat_id IS NULL";
+                               } else {
+                                       $cat_qpart = "cat_id = '$feed_id'";
+                               }
+
+                               /* Update counters for our child feeds */
+
+                               $result = db_query($link, "SELECT id FROM ttrss_feeds
+                                               WHERE owner_uid = '$owner_uid' AND $cat_qpart");
+
+                               while ($line = db_fetch_assoc($result)) {
+                                       ccache_update($link, $line["id"], $owner_uid, false, true);
+                               }
+
+                               /* With that done, update our own counter again */
+
+                               ccache_update($link, $feed_id, $owner_uid, true, true);
+
                        }
                }