]> git.wh0rd.org Git - tt-rss.git/commitdiff
fix add_feed_category
authorAndrew Dolgov <noreply@fakecake.org>
Fri, 1 Dec 2017 19:17:04 +0000 (22:17 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Fri, 1 Dec 2017 19:17:04 +0000 (22:17 +0300)
include/functions.php

index c28460dff1e330036db1c6611c8342dbf9fbb4ca..4154d8d5e82293bf5d6cac94a40237eb0f1a32d5 100644 (file)
                if (!$feed_cat) return false;
 
                $feed_cat = mb_substr($feed_cat, 0, 250);
+               if (!$parent_cat_id) $parent_cat_id = null;
 
                $pdo = Db::pdo();
                $pdo->beginTransaction();
 
                $sth = $pdo->prepare("SELECT id FROM ttrss_feed_categories
                                WHERE (parent_cat = :parent OR (:parent IS NULL AND parent_cat IS NULL)) 
-                               AND title = :cat AND owner_uid = :uid");
+                               AND title = :title AND owner_uid = :uid");
                $sth->execute([':parent' => $parent_cat_id, ':title' => $feed_cat, ':uid' => $_SESSION['uid']]);
 
-               if ($sth->fetch()) {
+               if (!$sth->fetch()) {
 
                        $sth = $pdo->prepare("INSERT INTO ttrss_feed_categories (owner_uid,title,parent_cat)
                                        VALUES (?, ?, ?)");