diff options
Diffstat (limited to 'include/rssfuncs.php')
-rw-r--r-- | include/rssfuncs.php | 72 |
1 files changed, 42 insertions, 30 deletions
diff --git a/include/rssfuncs.php b/include/rssfuncs.php index 4cd0f6888..a27a91747 100644 --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -671,9 +671,11 @@ if (db_num_rows($result) != 0) { $base_entry_id = db_fetch_result($result, 0, "id"); $entry_stored_hash = db_fetch_result($result, 0, "content_hash"); + $article_labels = get_article_labels($base_entry_id, $owner_uid); } else { $base_entry_id = false; $entry_stored_hash = ""; + $article_labels = array(); } $article = array("owner_uid" => $owner_uid, // read only @@ -681,8 +683,10 @@ "title" => $entry_title, "content" => $entry_content, "link" => $entry_link, + "labels" => $article_labels, // current limitation: can add labels to article, can't remove them "tags" => $entry_tags, "author" => $entry_author, + "force_catchup" => false, // ugly hack for the time being "language" => $entry_language, // read only "feed" => array("id" => $feed, "fetch_url" => $fetch_url, @@ -737,6 +741,15 @@ $entry_author = db_escape_string($article["author"]); $entry_link = db_escape_string($article["link"]); $entry_content = $article["content"]; // escaped below + $entry_force_catchup = $article["force_catchup"]; + $article_labels = $article["labels"]; + + if ($debug_enabled) { + _debug("article labels:", $debug_enabled); + print_r($article_labels); + } + + _debug("force catchup: $entry_force_catchup"); if ($cache_images && is_writable(CACHE_DIR . '/images')) cache_images($entry_content, $site_url, $debug_enabled); @@ -786,12 +799,8 @@ '$entry_language', '$entry_author')"); - $article_labels = array(); - } else { $base_entry_id = db_fetch_result($result, 0, "id"); - - $article_labels = get_article_labels($base_entry_id, $owner_uid); } // now it should exist, if not - bad luck then @@ -861,7 +870,7 @@ _debug("user record not found, creating...", $debug_enabled); - if ($score >= -500 && !find_article_filter($article_filters, 'catchup')) { + if ($score >= -500 && !find_article_filter($article_filters, 'catchup') && !$entry_force_catchup) { $unread = 'true'; $last_read_qpart = 'NULL'; } else { @@ -883,7 +892,7 @@ // N-grams - if (DB_TYPE == "pgsql" and defined('_NGRAM_TITLE_DUPLICATE_THRESHOLD')) { + /* if (DB_TYPE == "pgsql" and defined('_NGRAM_TITLE_DUPLICATE_THRESHOLD')) { $result = db_query("SELECT COUNT(*) AS similar FROM ttrss_entries,ttrss_user_entries @@ -898,7 +907,7 @@ if ($ngram_similar > 0) { $unread = 'false'; } - } + } */ $last_marked = ($marked == 'true') ? 'NOW()' : 'NULL'; $last_published = ($published == 'true') ? 'NOW()' : 'NULL'; @@ -958,7 +967,13 @@ db_query("COMMIT"); - _debug("assigning labels...", $debug_enabled); + _debug("assigning labels [other]...", $debug_enabled); + + foreach ($article_labels as $label) { + label_add_article($entry_ref_id, $label[1], $owner_uid); + } + + _debug("assigning labels [filters]...", $debug_enabled); assign_article_to_label_filters($entry_ref_id, $article_filters, $owner_uid, $article_labels); @@ -1087,20 +1102,6 @@ db_query("COMMIT"); } - if (get_pref("AUTO_ASSIGN_LABELS", $owner_uid, false)) { - _debug("auto-assigning labels...", $debug_enabled); - - foreach ($labels as $label) { - $caption = preg_quote($label["caption"]); - - if ($caption && preg_match("/\b$caption\b/i", "$tags_str " . strip_tags($entry_content) . " $entry_title")) { - if (!labels_contains_caption($article_labels, $caption)) { - label_add_article($entry_ref_id, $caption, $owner_uid); - } - } - } - } - _debug("article processed", $debug_enabled); } @@ -1165,16 +1166,8 @@ file_put_contents($local_filename, $file_content); } } - - /* if (file_exists($local_filename)) { - $entry->setAttribute('src', SELF_URL_PATH . '/image.php?url=' . - base64_encode($src)); - } */ } } - - //$node = $doc->getElementsByTagName('body')->item(0); - //return $doc->saveXML($node); } function expire_error_log($debug) { @@ -1400,6 +1393,24 @@ return $error; } */ + function cleanup_counters_cache($debug) { + $result = db_query("DELETE FROM ttrss_counters_cache + WHERE feed_id > 0 AND + (SELECT COUNT(id) FROM ttrss_feeds WHERE + id = feed_id AND + ttrss_counters_cache.owner_uid = ttrss_feeds.owner_uid) = 0"); + $frows = db_affected_rows($result); + + $result = db_query("DELETE FROM ttrss_cat_counters_cache + WHERE feed_id > 0 AND + (SELECT COUNT(id) FROM ttrss_feed_categories WHERE + id = feed_id AND + ttrss_cat_counters_cache.owner_uid = ttrss_feed_categories.owner_uid) = 0"); + $crows = db_affected_rows($result); + + _debug("Removed $frows (feeds) $crows (cats) orphaned counter cache entries."); + } + function housekeeping_common($debug) { expire_cached_files($debug); expire_lock_files($debug); @@ -1409,6 +1420,7 @@ _debug("Feedbrowser updated, $count feeds processed."); purge_orphans( true); + cleanup_counters_cache($debug); $rc = cleanup_tags( 14, 50000); _debug("Cleaned $rc cached tags."); |