]> git.wh0rd.org - tt-rss.git/blobdiff - classes/ccache.php
rssutils: PDO
[tt-rss.git] / classes / ccache.php
index 0562c888c2d1f9e3bfbd56d61de22d4a458feeb0..88e28e9e83e6ba23642fc90693f9b9fb720c2ad1 100644 (file)
@@ -118,7 +118,8 @@ class CCache {
 
                        if (!$pcat_fast) {
                                $sth = $pdo->prepare("SELECT id FROM ttrss_feeds
-                                               WHERE owner_uid = :uid AND cat_id = :cat OR (:cat = 0 AND cat_id IS NULL)");
+                                               WHERE owner_uid = :uid AND 
+                                                       (cat_id = :cat OR (:cat = 0 AND cat_id IS NULL))");
                                $sth->execute([":uid" => $owner_uid, ":cat" => $feed_id]);
 
                                while ($line = $sth->fetch()) {
@@ -129,7 +130,7 @@ class CCache {
                        $sth = $pdo->prepare("SELECT SUM(value) AS sv
                                FROM ttrss_counters_cache, ttrss_feeds
                                WHERE id = feed_id AND 
-                               cat_id = :cat OR (:cat IS NULL AND cat_id IS NULL) AND
+                               (cat_id = :cat OR (:cat = 0 AND cat_id IS NULL)) AND
                                ttrss_counters_cache.owner_uid = :uid AND
                                ttrss_feeds.owner_uid = :uid");
                        $sth->execute([":uid" => $owner_uid, ":cat" => $feed_id]);
@@ -141,7 +142,13 @@ class CCache {
                        $unread = (int) Feeds::getFeedArticles($feed_id, $is_cat, true, $owner_uid);
                }
 
-               $pdo->beginTransaction();
+               $tr_in_progress = false;
+
+               try {
+                       $pdo->beginTransaction();
+               } catch (Exception $e) {
+                       $tr_in_progress = true;
+               }
 
                $sth = $pdo->prepare("SELECT feed_id FROM $table
                        WHERE owner_uid = ? AND feed_id = ? LIMIT 1");
@@ -163,7 +170,7 @@ class CCache {
                        $sth->execute([$feed_id, $unread, $owner_uid]);
                }
 
-               $pdo->commit();
+               if (!$tr_in_progress) $pdo->commit();
 
                if ($feed_id > 0 && $prev_unread != $unread) {