diff --git a/models/feed.php b/models/feed.php
index 3783fe5..f3264bc 100644
--- a/models/feed.php
+++ b/models/feed.php
@@ -16,25 +16,30 @@ use PicoFeed\Client\InvalidUrlException;
const LIMIT_ALL = -1;
-// Download and store the favicon
-function fetch_favicon($feed_id, $site_url)
+// Store the favicon
+function store_favicon($feed_id, $link, $icon)
{
- $favicon = new Favicon;
-
return Database::get('db')
->table('favicons')
->save(array(
'feed_id' => $feed_id,
- 'link' => $favicon->find($site_url),
- 'icon' => $favicon->getDataUri(),
+ 'link' => $link,
+ 'icon' => $icon,
));
}
-// Refresh favicon
-function refresh_favicon($feed_id, $site_url)
+// Download favicon
+function fetch_favicon($feed_id, $site_url)
{
if (Config\get('favicons') == 1 && ! has_favicon($feed_id)) {
- fetch_favicon($feed_id, $site_url);
+ $favicon = new Favicon;
+
+ $link = $favicon->find($site_url);
+ $icon = $favicon->getDataUri();
+
+ if ($icon !== '') {
+ store_favicon($feed_id, $link, $icon);
+ }
}
}
@@ -63,7 +68,7 @@ function get_item_favicons(array $items)
$feed_ids = array();
foreach ($items as $item) {
- $feeds_ids[] = $item['feed_id'];
+ $feed_ids[] = $item['feed_id'];
}
return get_favicons($feed_ids);
@@ -184,7 +189,7 @@ function create($url, $enable_grabber = false, $force_rtl = false)
$feed_id = $db->getConnection()->getLastId();
Item\update_all($feed_id, $feed->getItems());
- refresh_favicon($feed_id, $feed->getSiteUrl());
+ fetch_favicon($feed_id, $feed->getSiteUrl());
Config\write_debug();
@@ -256,7 +261,7 @@ function refresh($feed_id)
update_cache($feed_id, $resource->getLastModified(), $resource->getEtag());
Item\update_all($feed_id, $feed->getItems());
- refresh_favicon($feed_id, $feed->getSiteUrl());
+ fetch_favicon($feed_id, $feed->getSiteUrl());
}
update_parsing_error($feed_id, 0);
diff --git a/models/proxy.php b/models/proxy.php
index 1badb22..8222101 100644
--- a/models/proxy.php
+++ b/models/proxy.php
@@ -13,12 +13,16 @@ function download($url)
$client->setUserAgent(Config\HTTP_USER_AGENT);
$client->execute($url);
- return array(
+ $content = array(
$client->getContent(),
$client->getContentType(),
);
}
catch (ClientException $e) {
- return array(false, false);
+ $content = array(false, false);
}
+
+ Config\write_debug();
+
+ return $content;
}
diff --git a/templates/show_item.php b/templates/show_item.php
index d4efc37..3be4e2d 100644
--- a/templates/show_item.php
+++ b/templates/show_item.php
@@ -76,7 +76,7 @@
-
+