]> git.wh0rd.org - tt-rss.git/commitdiff
further reduce db hit on tags in viewfeed
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 11 Nov 2011 08:34:12 +0000 (12:34 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 11 Nov 2011 08:34:12 +0000 (12:34 +0400)
functions.php

index 4f1b81f2d1cac6a81bce4f8c2c9485ce8c1de12b..fd89f5099908e2a5f6e55f08db38514c9e82b8c9 100644 (file)
                return $feedlist;
        }
 
-       function get_article_tags($link, $id, $owner_uid = 0) {
+       function get_article_tags($link, $id, $owner_uid = 0, $tag_cache = false) {
 
                global $memcache;
 
                } else {
                        /* check cache first */
 
-                       $result = db_query($link, "SELECT tag_cache FROM ttrss_user_entries
-                               WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
+                       if ($tag_cache === false) {
+                               $result = db_query($link, "SELECT tag_cache FROM ttrss_user_entries
+                                       WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
 
-                       $tag_cache = db_fetch_result($result, 0, "tag_cache");
+                               $tag_cache = db_fetch_result($result, 0, "tag_cache");
+                       }
 
                        if ($tag_cache) {
                                $tags = explode(",", $tag_cache);
 
                                        $tag_cache = $line["tag_cache"];
 
-                                       if ($tag_cache)
-                                               $tags_str = format_tags_string(explode(",", $tag_cache), $id);
-                                       else
-                                               $tags_str = format_tags_string(get_article_tags($link, $id), $id);
+                                       $tags_str = format_tags_string(
+                                               get_article_tags($link, $id, $_SESSION["uid"], $tag_cache),
+                                               $id);
 
                                        $reply['content'] .= "<img src='".theme_image($link,
                                                        'images/tag.png')."' alt='Tags' title='Tags'>