diff options
| author | 2025-08-01 08:30:49 +0200 | |
|---|---|---|
| committer | 2025-08-01 08:30:49 +0200 | |
| commit | e915ebe46ecc76bd00e19a9cc63764ff2e277315 (patch) | |
| tree | 4cb7caf3c8ad5328dab45097c3f92acabc621f5b /app/Models/Feed.php | |
| parent | 188cc0d063b15be22cdd230b808c0bce5cff68e7 (diff) | |
Rework fetch favicons (#7767)
* Use main function `httpGet()` instead of local one;
* Use HTTP cache, also between users;
* Do not default to feed URL when there is no website URL
TODO for later: consider supporting Atom's `<icon>` and RSS 2.0's `<image>` https://github.com/FreshRSS/FreshRSS/issues/7774
Diffstat (limited to 'app/Models/Feed.php')
| -rw-r--r-- | app/Models/Feed.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 81765d433..2b442561e 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -176,6 +176,8 @@ class FreshRSS_Feed extends Minz_Model { } $attributesOnly = $contents === null && $tmpPath === ''; + + require_once(LIB_PATH . '/favicons.php'); if (!$attributesOnly && !isImgMime(is_string($contents) ? $contents : '')) { throw new FreshRSS_UnsupportedImageFormat_Exception(); } @@ -195,7 +197,6 @@ class FreshRSS_Feed extends Minz_Model { $this->_attribute('customFaviconExt', $extName); $this->_attribute('customFaviconDisallowDel', $disallowDelete); - require_once(LIB_PATH . '/favicons.php'); $newPath = FAVICONS_DIR . $this->hashFavicon(skipCache: true) . '.ico'; if ($attributesOnly && !file_exists($newPath)) { $updateFeed = false; @@ -404,7 +405,12 @@ class FreshRSS_Feed extends Minz_Model { if ($this->customFavicon()) { return; } - $url = $this->website(fallback: true); + $url = $this->website(fallback: false); + if ($url === '' || $url === $this->url) { + // Get root URL from the feed URL + $url = preg_replace('%^(https?://[^/]+).*$%i', '$1/', $this->url) ?? $this->url; + } + $txt = FAVICONS_DIR . $this->hashFavicon() . '.txt'; if (@file_get_contents($txt) !== $url) { file_put_contents($txt, $url); |
