From: Andrew Dolgov Date: Thu, 25 Oct 2012 09:15:14 +0000 (+0400) Subject: force refetch feed when clicking update/clicking on same feed in the tree X-Git-Tag: 1.6.1~65 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=c0c2abbaa73363a1349e41ec08cd54a0d1e8ad8e;p=tt-rss.git force refetch feed when clicking update/clicking on same feed in the tree --- diff --git a/classes/feeds.php b/classes/feeds.php index 836bbb06..df206c2e 100644 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -134,9 +134,20 @@ class Feeds extends Handler_Protected { $method_split = explode(":", $method); - if ($method == "ForceUpdate" && $feed && is_numeric($feed) > 0) { - include "rssfuncs.php"; - update_rss_feed($this->link, $feed, true); + if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) { + // Update the feed if required with some basic flood control + + $result = db_query($this->link, + "SELECT ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated + FROM ttrss_feeds WHERE id = '$feed'"); + + if (db_num_rows($result) != 0) { + $last_updated = strtotime(db_fetch_result($result, 0, "last_updated")); + if (time() - $last_updated > 120) { + include "rssfuncs.php"; + update_rss_feed($this->link, $feed, true, true); + } + } } if ($method_split[0] == "MarkAllReadGR") { diff --git a/include/rssfuncs.php b/include/rssfuncs.php index 09fd457b..14fa5f34 100644 --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -269,7 +269,7 @@ define('MAGPIE_CACHE_AGE', $cache_age); define('MAGPIE_CACHE_ON', !$no_cache); - define('MAGPIE_FETCH_TIME_OUT', 60); + define('MAGPIE_FETCH_TIME_OUT', $no_cache ? 15 : 60); define('MAGPIE_CACHE_DIR', CACHE_DIR . "/magpie"); $rss = @fetch_rss($fetch_url); @@ -282,7 +282,7 @@ $rss = new SimplePie(); $rss->set_useragent(SELF_USER_AGENT); -# $rss->set_timeout(10); + $rss->set_timeout($no_cache ? 15 : 60); $rss->set_feed_url($fetch_url); $rss->set_output_encoding('UTF-8'); //$rss->force_feed(true); diff --git a/index.php b/index.php index 4c4fa541..09c4dc8c 100644 --- a/index.php +++ b/index.php @@ -184,7 +184,7 @@