From 25aeaf4801c861abe74b2f50502d034ac8f40e6d Mon Sep 17 00:00:00 2001 From: Dustin Wilson Date: Sun, 2 Apr 2017 21:23:15 -0500 Subject: [PATCH] Grab favicon from site's URL, not the feed's MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Changed Feed to where the favicon is gotten when parsing so the feed’s site URL is used instead of the feed’s for favicons. Some feeds don’t have the same domain. • Fixed a bug in Database. --- lib/Database.php | 2 +- lib/Feed.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Database.php b/lib/Database.php index ac319cd..e2ada44 100644 --- a/lib/Database.php +++ b/lib/Database.php @@ -499,7 +499,7 @@ class Database { try { $feed = new Feed($f['url'], $f['lastmodified'], $f['etag'], $f['username'], $f['password']); } catch (Feed\Exception $e) { - $this->db->prepare('UPDATE arsse_feeds SET err_count = err_count + 1, err_msg = "" WHERE id is ?', 'str', 'int')->run( + $this->db->prepare('UPDATE arsse_feeds SET err_count = err_count + 1, err_msg = ? WHERE id is ?', 'str', 'int')->run( $e->getMessage(), $f['id'] ); diff --git a/lib/Feed.php b/lib/Feed.php index 1c606b1..b6f4364 100644 --- a/lib/Feed.php +++ b/lib/Feed.php @@ -21,8 +21,6 @@ class Feed { $this->reader = new Reader($config); $this->resource = $this->reader->download($url, $lastModified, $etag, $username, $password); - // Grab the favicon for the feed; returns an empty string if it cannot find one. - $this->favicon = (new Favicon)->find($url); } catch (PicoFeedException $e) { throw new Feed\Exception($url, $e); } @@ -36,6 +34,11 @@ class Feed { $this->resource->getEncoding() ); $feed = $this->parser->execute(); + + // Grab the favicon for the feed; returns an empty string if it cannot find one. + // Some feeds might use a different domain (eg: feedburner), so the site url is + // used instead of the feed's url. + $this->favicon = (new Favicon)->find($siteUrl); } catch (PicoFeedException $e) { throw new Feed\Exception($url, $e); }