summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2012-10-24 11:59:36 +0400
committerAndrew Dolgov <[email protected]>2012-10-24 11:59:36 +0400
commit2680295b1958c9890ff3fafa0f82ba506d11a87d (patch)
treeba66073d67ea193f8842b06a233942c7b411edbb /include
parent3de78afd3bc9b01da3a03391dc566430b490886c (diff)
fix sql crash workaround preventing feed/category filters from testing
properly; fix filter testing for categories with children
Diffstat (limited to 'include')
-rw-r--r--include/functions.php21
1 files changed, 17 insertions, 4 deletions
diff --git a/include/functions.php b/include/functions.php
index ccaea76ac..4c88c0350 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -2321,10 +2321,11 @@
$override_order = "updated DESC";
- $filter_query_part = filter_to_sql($filter);
+ $filter_query_part = filter_to_sql($link, $filter, $owner_uid);
// Try to check if SQL regexp implementation chokes on a valid regexp
- $result = db_query($link, "SELECT true AS true FROM ttrss_entries
+ $result = db_query($link, "SELECT true AS true FROM ttrss_entries,
+ ttrss_user_entries, ttrss_feeds, ttrss_feed_categories
WHERE $filter_query_part LIMIT 1", false);
$test = db_fetch_result($result, 0, "true");
@@ -5110,7 +5111,7 @@
return $html;
}
- function filter_to_sql($filter) {
+ function filter_to_sql($link, $filter, $owner_uid) {
$query = array();
if (DB_TYPE == "pgsql")
@@ -5159,7 +5160,19 @@
}
if (isset($rule["cat_id"])) {
- $qpart .= " AND cat_id " . ($rule["cat_id"] ? '= ' . $rule["cat_id"] : 'IS NULL');
+
+ if ($rule["cat_id"] > 0) {
+ $children = getChildCategories($link, $rule["cat_id"], $owner_uid);
+ array_push($children, $rule["cat_id"]);
+
+ $children = join(",", $children);
+
+ $cat_qpart = "cat_id IN ($children)";
+ } else {
+ $cat_qpart = "cat_id IS NULL";
+ }
+
+ $qpart .= " AND $cat_qpart";
}
array_push($query, "($qpart)");