From 36490f11a3d7bf42e3725d4bb0884f3d0e49e4d8 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 23 Apr 2013 22:30:06 +0400 Subject: [PATCH] add a hack so that if floicon fails on some icon, it won't be processed again --- include/rssfuncs.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/rssfuncs.php b/include/rssfuncs.php index 2be791cb..8bc5fcbd 100644 --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -399,7 +399,7 @@ $favicon_interval_qpart = "favicon_last_checked < DATE_SUB(NOW(), INTERVAL 12 HOUR)"; } - $result = db_query("SELECT title,site_url,owner_uid, + $result = db_query("SELECT title,site_url,owner_uid,favicon_avg_color, (favicon_last_checked IS NULL OR $favicon_interval_qpart) AS favicon_needs_check FROM ttrss_feeds WHERE id = '$feed'"); @@ -408,24 +408,34 @@ $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")); + $favicon_avg_color = db_fetch_result($result, 0, "favicon_avg_color"); $owner_uid = db_fetch_result($result, 0, "owner_uid"); $site_url = db_escape_string(mb_substr(rewrite_relative_url($fetch_url, $rss->get_link()), 0, 245)); if ($favicon_needs_check || $force_refetch) { + + /* terrible hack: if we crash on floicon shit here, we won't check + * the icon avgcolor again */ + + db_query("UPDATE ttrss_feeds SET favicon_avg_color = 'fail' WHERE + id = '$feed'"); + _debug("checking favicon...", $debug_enabled); check_feed_favicon($site_url, $feed, $link); $favicon_file = ICONS_DIR . "/$feed.ico"; - if (file_exists($favicon_file) && function_exists("imagecreatefromstring")) { + if (file_exists($favicon_file) && function_exists("imagecreatefromstring") && $favicon_avg_color != 'fail') { require_once "colors.php"; $favicon_color = db_escape_string( calculate_avg_color($favicon_file)); $favicon_colorstring = ",favicon_avg_color = '".$favicon_color."'"; + } else if ($favicon_avg_color == 'fail') { + _debug("floicon failed on this file, not trying to recalculate avg color"); } db_query("UPDATE ttrss_feeds SET favicon_last_checked = NOW() -- 2.39.2