]> git.wh0rd.org - tt-rss.git/blobdiff - include/functions.php
OPML: use PDO; minor fixes
[tt-rss.git] / include / functions.php
index f09d72cd079607803da01d0cd31387562fb887b2..31a0300d75428733241358be45b306ce1dc20d9f 100644 (file)
        function load_filters($feed_id, $owner_uid) {
                $filters = array();
 
+               $feed_id = (int) $feed_id;
                $cat_id = (int)Feeds::getFeedCategory($feed_id);
 
                if ($cat_id == 0)
                if (!$parent_cat_id) $parent_cat_id = null;
 
                $pdo = Db::pdo();
-               $pdo->beginTransaction();
+               $tr_in_progress = false;
+
+               try {
+                       $pdo->beginTransaction();
+               } catch (Exception $e) {
+                       $tr_in_progress = true;
+               }
 
                $sth = $pdo->prepare("SELECT id FROM ttrss_feed_categories
                                WHERE (parent_cat = :parent OR (:parent IS NULL AND parent_cat IS NULL)) 
                                        VALUES (?, ?, ?)");
                        $sth->execute([$_SESSION['uid'], $feed_cat, $parent_cat_id]);
 
-                       $pdo->commit();
+                       if (!$tr_in_progress) $pdo->commit();
 
                        return true;
                }