// Test if feed is currently being updated by another process.
if (DB_TYPE == "pgsql") {
- $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < NOW() - INTERVAL '10 minutes')";
+ $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < NOW() - INTERVAL '1 minutes')";
} else {
- $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < DATE_SUB(NOW(), INTERVAL 10 MINUTE))";
+ $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < DATE_SUB(NOW(), INTERVAL 1 MINUTE))";
}
// Test if there is a limit to number of updated feeds
$query = "SELECT DISTINCT ttrss_feeds.feed_url, ttrss_feeds.last_updated
FROM
ttrss_feeds, ttrss_users, ttrss_user_prefs
- WHERE
+ WHERE
+ ttrss_feeds.feed_url like '%tt-rss%feed%' AND
ttrss_feeds.owner_uid = ttrss_users.id
AND ttrss_users.id = ttrss_user_prefs.owner_uid
AND ttrss_user_prefs.pref_name = 'DEFAULT_UPDATE_INTERVAL'
// since we have the data cached, we can deal with other feeds with the same url
- $tmp_result = db_query("SELECT DISTINCT ttrss_feeds.id,last_updated
+ $tmp_result = db_query("SELECT DISTINCT ttrss_feeds.id,last_updated,ttrss_feeds.owner_uid
FROM ttrss_feeds, ttrss_users, ttrss_user_prefs WHERE
ttrss_user_prefs.owner_uid = ttrss_feeds.owner_uid AND
ttrss_users.id = ttrss_user_prefs.owner_uid AND
if (db_num_rows($tmp_result) > 0) {
while ($tline = db_fetch_assoc($tmp_result)) {
- if($debug) _debug(" => " . $tline["last_updated"] . ", " . $tline["id"]);
+ if($debug) _debug(" => " . $tline["last_updated"] . ", " . $tline["id"] . " " . $tline["owner_uid"]);
update_rss_feed($tline["id"], true);
++$nf;
}
return false;
}
- // set last update to now so if anything *simplepie* crashes later we won't be
- // continuously failing on the same feed
- db_query("UPDATE ttrss_feeds SET last_updated = NOW() WHERE id = '$feed'");
-
$last_updated = db_fetch_result($result, 0, "last_updated");
$last_article_timestamp = @strtotime(db_fetch_result($result, 0, "last_article_timestamp"));
+
+ if (defined('_DISABLE_HTTP_304'))
+ $last_article_timestamp = 0;
+
$owner_uid = db_fetch_result($result, 0, "owner_uid");
$mark_unread_on_update = sql_bool_to_bool(db_fetch_result($result,
0, "mark_unread_on_update"));
$date_feed_processed = date('Y-m-d H:i');
- $cache_filename = CACHE_DIR . "/simplepie/" . sha1($fetch_url) . ".feed2";
-
- // Ignore cache if new feed or manual update.
- $cache_age = ($no_cache || is_null($last_updated) || strpos($last_updated, '1970-01-01') === 0) ? 30 : get_feed_update_interval($feed) * 60;
-
- _debug("cache filename: $cache_filename exists: " . file_exists($cache_filename), $debug_enabled);
- _debug("cache age: $cache_age; no cache: $no_cache", $debug_enabled);
-
- $cached_feed_data_hash = false;
+ $cache_filename = CACHE_DIR . "/simplepie/" . sha1($fetch_url) . ".xml";
$rss = false;
$rss_hash = false;
if (file_exists($cache_filename) &&
is_readable($cache_filename) &&
!$auth_login && !$auth_pass &&
- filemtime($cache_filename) > time() - $cache_age) {
+ filemtime($cache_filename) > time() - 30) {
- _debug("using local cache.", $debug_enabled);
+ _debug("using local cache.", $debug_enabled);
- if ($cache_timestamp > $last_article_timestamp) {
- @$feed_data = file_get_contents($cache_filename);
+ @$feed_data = file_get_contents($cache_filename);
+
+ if ($feed_data) {
+ $rss_hash = sha1($feed_data);
+ }
- if ($feed_data) {
- $rss_hash = sha1($feed_data);
- }
- } else if (!$force_refetch) {
- _debug("local cache valid and older than last_updated, nothing to do.", $debug_enabled);
- return;
- }
} else {
_debug("local cache will not be used for this feed", $debug_enabled);
}
$feed_data = $plugin->hook_feed_fetched($feed_data);
}
+ // set last update to now so if anything *simplepie* crashes later we won't be
+ // continuously failing on the same feed
+ //db_query("UPDATE ttrss_feeds SET last_updated = NOW() WHERE id = '$feed'");
+
if (!$rss) {
$rss = new FeedParser($feed_data);
$rss->init();
$feed_title = db_escape_string($rss->get_title());
- _debug("registering title: $feed_title", $debug_enabled);
+ if ($feed_title) {
+ _debug("registering title: $feed_title", $debug_enabled);
- db_query("UPDATE ttrss_feeds SET
- title = '$feed_title' WHERE id = '$feed'");
+ db_query("UPDATE ttrss_feeds SET
+ title = '$feed_title' WHERE id = '$feed'");
+ }
}
if ($site_url && $orig_site_url != $site_url) {
$entry_comments = db_escape_string(mb_substr(trim($entry_comments), 0, 245));
$entry_author = db_escape_string(mb_substr(trim($entry_author), 0, 245));
- $num_comments = $item->get_comments_count();
-
- if (is_array($num_comments) && is_array($num_comments[0])) {
- $num_comments = (int) $num_comments[0]["data"];
- } else {
- $num_comments = 0;
- }
+ $num_comments = (int) $item->get_comments_count();
_debug("author $entry_author", $debug_enabled);
_debug("num_comments: $num_comments", $debug_enabled);
- _debug("looking for tags [1]...", $debug_enabled);
+ _debug("looking for tags...", $debug_enabled);
// parse <category> entries into tags
}
}
- _debug("category tags:", $debug_enabled);
- _debug("looking for tags [2]...", $debug_enabled);
-
$entry_tags = array_unique($additional_tags);
for ($i = 0; $i < count($entry_tags); $i++)
$entry_tags[$i] = mb_strtolower($entry_tags[$i], 'utf-8');
+ _debug("tags found: " . join(",", $entry_tags), $debug_enabled);
+
_debug("done collecting data.", $debug_enabled);
// TODO: less memory-hungry implementation