From f0f7a5f9589348e27fa66b1a02e90d669bfc6874 Mon Sep 17 00:00:00 2001 From: wn_ Date: Fri, 3 Feb 2023 00:45:04 +0000 Subject: [PATCH 1/5] Ensure custom favicon color detection happens. --- classes/rssutils.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classes/rssutils.php b/classes/rssutils.php index 561171d09..b3363954c 100755 --- a/classes/rssutils.php +++ b/classes/rssutils.php @@ -600,7 +600,8 @@ class RSSUtils { Debug::log("favicon: needs check: {$feed_obj->favicon_needs_check} is custom: {$feed_obj->favicon_is_custom} avg color: {$feed_obj->favicon_avg_color}", Debug::LOG_VERBOSE); - if ($feed_obj->favicon_needs_check || $force_refetch) { + if ($feed_obj->favicon_needs_check || $force_refetch + || ($feed_obj->favicon_is_custom && !$feed_obj->favicon_avg_color)) { // restrict update attempts to once per 12h $feed_obj->favicon_last_checked = Db::NOW(); From 380624a4840f99457b23ed3223f37d4d79b9d1f2 Mon Sep 17 00:00:00 2001 From: wn_ Date: Fri, 3 Feb 2023 01:02:38 +0000 Subject: [PATCH 2/5] Persist failure to detect favicon average color. Previously, an empty string returned by '\Colors\calculate_avg_color()' would be set as the 'favicon_avg_color' value, resulting in always reattempting average color calculation. --- classes/rssutils.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/classes/rssutils.php b/classes/rssutils.php index b3363954c..26e9dd033 100755 --- a/classes/rssutils.php +++ b/classes/rssutils.php @@ -633,12 +633,14 @@ class RSSUtils { $feed_obj->save(); $feed_obj->favicon_avg_color = \Colors\calculate_avg_color($favicon_cache->get_full_path($feed)); - $feed_obj->save(); + if ($feed_obj->favicon_avg_color) { + $feed_obj->save(); + } Debug::log("favicon: avg color: {$feed_obj->favicon_avg_color}", Debug::LOG_VERBOSE); } else if ($feed_obj->favicon_avg_color == 'fail') { - Debug::log("floicon failed on $feed, not trying to recalculate avg color", Debug::LOG_VERBOSE); + Debug::log("floicon failed on $feed or a suitable avg color couldn't be determined, not trying to recalculate avg color", Debug::LOG_VERBOSE); } } From f484988967511a45b871e8820d5a9b90de5781ba Mon Sep 17 00:00:00 2001 From: wn_ Date: Fri, 3 Feb 2023 01:17:50 +0000 Subject: [PATCH 3/5] Fix logging favicon-related bools in 'RSSUtils::update_rss_feed()'. --- classes/rssutils.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/classes/rssutils.php b/classes/rssutils.php index 26e9dd033..1c07e601c 100755 --- a/classes/rssutils.php +++ b/classes/rssutils.php @@ -597,7 +597,9 @@ class RSSUtils { Debug::log("site_url: {$feed_obj->site_url}", Debug::LOG_VERBOSE); Debug::log("feed_title: {$rss->get_title()}", Debug::LOG_VERBOSE); - Debug::log("favicon: needs check: {$feed_obj->favicon_needs_check} is custom: {$feed_obj->favicon_is_custom} avg color: {$feed_obj->favicon_avg_color}", + Debug::log('favicon: needs check: ' . ($feed_obj->favicon_needs_check ? 'true' : 'false') + . ', is custom: ' . ($feed_obj->favicon_is_custom ? 'true' : 'false') + . ", avg color: {$feed_obj->favicon_avg_color}", Debug::LOG_VERBOSE); if ($feed_obj->favicon_needs_check || $force_refetch From b28d339bf2d21813864a420e0ae0332d86ce56ae Mon Sep 17 00:00:00 2001 From: wn_ Date: Fri, 3 Feb 2023 01:28:15 +0000 Subject: [PATCH 4/5] Don't set 'favicon_avg_color' on feed obj unless it's valid. --- classes/rssutils.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/classes/rssutils.php b/classes/rssutils.php index 1c07e601c..daa856a0d 100755 --- a/classes/rssutils.php +++ b/classes/rssutils.php @@ -634,8 +634,9 @@ class RSSUtils { $feed_obj->favicon_avg_color = 'fail'; $feed_obj->save(); - $feed_obj->favicon_avg_color = \Colors\calculate_avg_color($favicon_cache->get_full_path($feed)); - if ($feed_obj->favicon_avg_color) { + $calculated_avg_color = \Colors\calculate_avg_color($favicon_cache->get_full_path($feed)); + if ($calculated_avg_color) { + $feed_obj->favicon_avg_color = $calculated_avg_color; $feed_obj->save(); } From 1646aba944bda7a90b02829d6eb47fa03f7cd1bd Mon Sep 17 00:00:00 2001 From: wn_ Date: Fri, 3 Feb 2023 01:30:35 +0000 Subject: [PATCH 5/5] Minor tweak to favicon avg color debug log message. --- classes/rssutils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/rssutils.php b/classes/rssutils.php index daa856a0d..df7727eb1 100755 --- a/classes/rssutils.php +++ b/classes/rssutils.php @@ -640,7 +640,7 @@ class RSSUtils { $feed_obj->save(); } - Debug::log("favicon: avg color: {$feed_obj->favicon_avg_color}", Debug::LOG_VERBOSE); + Debug::log("favicon: calculated avg color: {$calculated_avg_color}, setting avg color: {$feed_obj->favicon_avg_color}", Debug::LOG_VERBOSE); } else if ($feed_obj->favicon_avg_color == 'fail') { Debug::log("floicon failed on $feed or a suitable avg color couldn't be determined, not trying to recalculate avg color", Debug::LOG_VERBOSE);