rate-limit requests for favicons when not present to conserve traffic (refs #457)
This commit is contained in:
parent
0e63fc49ab
commit
382268c6c9
|
@ -414,12 +414,22 @@
|
|||
|
||||
// db_query($link, "BEGIN");
|
||||
|
||||
$result = db_query($link, "SELECT title,icon_url,site_url,owner_uid
|
||||
if (DB_TYPE == "pgsql") {
|
||||
$favicon_interval_qpart = "favicon_last_checked < NOW() - INTERVAL '12 hour'";
|
||||
} else {
|
||||
$favicon_interval_qpart = "favicon_last_checked < DATE_SUB(NOW(), INTERVAL 12 HOUR)";
|
||||
}
|
||||
|
||||
$result = db_query($link, "SELECT title,icon_url,site_url,owner_uid,
|
||||
(favicon_last_checked IS NULL OR $favicon_interval_qpart) AS
|
||||
favicon_needs_check
|
||||
FROM ttrss_feeds WHERE id = '$feed'");
|
||||
|
||||
$registered_title = db_fetch_result($result, 0, "title");
|
||||
$orig_icon_url = db_fetch_result($result, 0, "icon_url");
|
||||
$orig_site_url = db_fetch_result($result, 0, "site_url");
|
||||
$favicon_needs_check = sql_bool_to_bool(db_fetch_result($result, 0,
|
||||
"favicon_needs_check"));
|
||||
|
||||
$owner_uid = db_fetch_result($result, 0, "owner_uid");
|
||||
|
||||
|
@ -441,7 +451,7 @@
|
|||
_debug("update_rss_feed: checking favicon...");
|
||||
}
|
||||
|
||||
check_feed_favicon($site_url, $feed, $link);
|
||||
if ($favicon_needs_check) check_feed_favicon($site_url, $feed, $link);
|
||||
|
||||
if (!$registered_title || $registered_title == "[Unknown]") {
|
||||
|
||||
|
@ -1285,7 +1295,9 @@
|
|||
purge_feed($link, $feed, 0, $debug_enabled);
|
||||
|
||||
db_query($link, "UPDATE ttrss_feeds
|
||||
SET last_updated = NOW(), last_error = '' WHERE id = '$feed'");
|
||||
SET last_updated = NOW(),
|
||||
favicon_last_checked = NOW(),
|
||||
last_error = '' WHERE id = '$feed'");
|
||||
|
||||
// db_query($link, "COMMIT");
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
} else {
|
||||
|
||||
define('EXPECTED_CONFIG_VERSION', 25);
|
||||
define('SCHEMA_VERSION', 91);
|
||||
define('SCHEMA_VERSION', 92);
|
||||
|
||||
require_once "config.php";
|
||||
require_once "sanity_config.php";
|
||||
|
|
|
@ -119,6 +119,7 @@ create table ttrss_feeds (id integer not null auto_increment primary key,
|
|||
update_on_checksum_change boolean not null default false,
|
||||
strip_images boolean not null default false,
|
||||
pubsub_state integer not null default 0,
|
||||
favicon_last_checked datetime default null,
|
||||
index(owner_uid),
|
||||
foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE,
|
||||
index(cat_id),
|
||||
|
@ -260,7 +261,7 @@ create table ttrss_tags (id integer primary key auto_increment,
|
|||
|
||||
create table ttrss_version (schema_version int not null) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
|
||||
|
||||
insert into ttrss_version values (91);
|
||||
insert into ttrss_version values (92);
|
||||
|
||||
create table ttrss_enclosures (id integer primary key auto_increment,
|
||||
content_url text not null,
|
||||
|
|
|
@ -82,6 +82,7 @@ create table ttrss_feeds (id serial not null primary key,
|
|||
update_on_checksum_change boolean not null default false,
|
||||
strip_images boolean not null default false,
|
||||
pubsub_state integer not null default 0,
|
||||
favicon_last_checked timestamp default null,
|
||||
auth_pass_encrypted boolean not null default false);
|
||||
|
||||
create index ttrss_feeds_owner_uid_index on ttrss_feeds(owner_uid);
|
||||
|
@ -229,7 +230,7 @@ create index ttrss_tags_post_int_id_idx on ttrss_tags(post_int_id);
|
|||
|
||||
create table ttrss_version (schema_version int not null);
|
||||
|
||||
insert into ttrss_version values (91);
|
||||
insert into ttrss_version values (92);
|
||||
|
||||
create table ttrss_enclosures (id serial not null primary key,
|
||||
content_url text not null,
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
begin;
|
||||
|
||||
alter table ttrss_feeds add column favicon_last_checked datetime;
|
||||
alter table ttrss_feeds alter column favicon_last_checked set default null;
|
||||
|
||||
update ttrss_version set schema_version = 92;
|
||||
|
||||
commit;
|
|
@ -0,0 +1,8 @@
|
|||
begin;
|
||||
|
||||
alter table ttrss_feeds add column favicon_last_checked timestamp;
|
||||
alter table ttrss_feeds alter column favicon_last_checked set default null;
|
||||
|
||||
update ttrss_version set schema_version = 92;
|
||||
|
||||
commit;
|
Loading…
Reference in New Issue