]> git.wh0rd.org Git - tt-rss.git/commitdiff
fix tag caching issues
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 10 Nov 2010 08:08:33 +0000 (11:08 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 10 Nov 2010 08:08:33 +0000 (11:08 +0300)
functions.php
modules/backend-rpc.php

index 3e8cb8205c0745ec9498e1d9d7572876879754b5..09efbd33209040bcc544011c5d9d8758c94d2b89 100644 (file)
                                        'BLACKLISTED_TAGS', $owner_uid, ''), 'utf-8')));
 
                                $filtered_tags = array();
+                               $tags_to_cache = array();
 
                                if ($entry_tags && is_array($entry_tags)) {
                                        foreach ($entry_tags as $tag) {
                                        }
                                } 
 
+                               $filtered_tags = array_unique($filtered_tags);
+
                                if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) {
                                        _debug("update_rss_feed: filtered article tags:");
                                        print_r($filtered_tags);
                                
                                        db_query($link, "BEGIN");
                        
-                                               foreach ($filtered_tags as $tag) {
+                                       foreach ($filtered_tags as $tag) {
 
-                                                       $tag = sanitize_tag($tag);
-                                                       $tag = db_escape_string($tag);
+                                               $tag = sanitize_tag($tag);
+                                               $tag = db_escape_string($tag);
+
+                                               if (!tag_is_valid($tag)) continue;
+                                               
+                                               $result = db_query($link, "SELECT id FROM ttrss_tags            
+                                                       WHERE tag_name = '$tag' AND post_int_id = '$entry_int_id' AND 
+                                                       owner_uid = '$owner_uid' LIMIT 1");
 
-                                                       if (!tag_is_valid($tag)) continue;
-                                                       
-                                                       $result = db_query($link, "SELECT id FROM ttrss_tags            
-                                                               WHERE tag_name = '$tag' AND post_int_id = '$entry_int_id' AND 
-                                                               owner_uid = '$owner_uid' LIMIT 1");
-       
                                                        if ($result && db_num_rows($result) == 0) {
                                                                
                                                                db_query($link, "INSERT INTO ttrss_tags 
                                                                        (owner_uid,tag_name,post_int_id)
                                                                        VALUES ('$owner_uid','$tag', '$entry_int_id')");
-                                                       }                                                       
+                                                       }
 
-                                                       /* update the cache */
+                                               array_push($tags_to_cache, $tag);
+                                       }
 
-                                                       $tags_str = db_escape_string(join(",", $filtered_tags));
+                                       /* update the cache */
+                                                       
+                                       $tags_to_cache = array_unique($tags_to_cache);
+               
+                                       $tags_str = db_escape_string(join(",", $tags_to_cache));
 
-                                                       db_query($link, "UPDATE ttrss_user_entries 
-                                                               SET tag_cache = '$tags_str' WHERE ref_id = '$entry_ref_id'
-                                                               AND owner_uid = $owner_uid");
-                                               }
+                                       db_query($link, "UPDATE ttrss_user_entries 
+                                               SET tag_cache = '$tags_str' WHERE ref_id = '$entry_ref_id'
+                                               AND owner_uid = $owner_uid");
 
                                        db_query($link, "COMMIT");
                                } 
index a825242c64363c7e519a09a4d63a46cfc7d47568..047558fc20e9a9e9bfaa245c2a08c8fac5e0336f 100644 (file)
 
                        $tags_str = db_escape_string($_REQUEST["tags_str"]);
                        $tags = array_unique(trim_array(split(",", $tags_str)));
-                       $tags_str = db_escape_string(join(",", $tags));
 
                        db_query($link, "BEGIN");
 
 
                        if (db_num_rows($result) == 1) {
 
+                               $tags_to_cache = array();
+
                                $int_id = db_fetch_result($result, 0, "int_id");
 
                                db_query($link, "DELETE FROM ttrss_tags WHERE 
                                                db_query($link, "INSERT INTO ttrss_tags 
                                                        (post_int_id, owner_uid, tag_name) VALUES ('$int_id', '".$_SESSION["uid"]."', '$tag')");
                                        }
+
+                                       array_push($tags_to_cache, $tag);
                                }
-                       }
 
-                       db_query($link, "UPDATE ttrss_user_entries 
-                               SET tag_cache = '$tags_str' WHERE ref_id = '$id'
-                               AND owner_uid = " . $_SESSION["uid"]);
+                               /* update tag cache */
+
+                               $tags_str = join(",", $tags_to_cache);
+
+                               db_query($link, "UPDATE ttrss_user_entries 
+                                       SET tag_cache = '$tags_str' WHERE ref_id = '$id'
+                                       AND owner_uid = " . $_SESSION["uid"]);
+                       }
 
                        db_query($link, "COMMIT");