From a6138225ea7863471ec66e3f51ab3192ac8a1112 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 6 Sep 2024 08:51:21 +0200 Subject: Better cache name for JSON feeds (#6768) --- app/Models/Feed.php | 19 +++++++++++++------ data/cache/.gitignore | 3 ++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 50495a361..36cc58cfd 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -905,12 +905,19 @@ class FreshRSS_Feed extends Minz_Model { } $url = htmlspecialchars_decode($this->url); $filename = $simplePie->get_cache_filename($url); - if ($this->kind === FreshRSS_Feed::KIND_HTML_XPATH) { - return CACHE_PATH . '/' . $filename . '.html'; - } elseif ($this->kind === FreshRSS_Feed::KIND_XML_XPATH) { - return CACHE_PATH . '/' . $filename . '.xml'; - } else { - return CACHE_PATH . '/' . $filename . '.spc'; + switch ($this->kind) { + case FreshRSS_Feed::KIND_HTML_XPATH: + return CACHE_PATH . '/' . $filename . '.html'; + case FreshRSS_Feed::KIND_XML_XPATH: + return CACHE_PATH . '/' . $filename . '.xml'; + case FreshRSS_Feed::KIND_JSON_DOTNOTATION: + case FreshRSS_Feed::KIND_JSON_XPATH: + case FreshRSS_Feed::KIND_JSONFEED: + return CACHE_PATH . '/' . $filename . '.json'; + case FreshRSS_Feed::KIND_RSS: + case FreshRSS_Feed::KIND_RSS_FORCED: + default: + return CACHE_PATH . '/' . $filename . '.spc'; } } diff --git a/data/cache/.gitignore b/data/cache/.gitignore index 36e4317f8..db4a3469c 100644 --- a/data/cache/.gitignore +++ b/data/cache/.gitignore @@ -1,4 +1,5 @@ -*.spc *.html +*.json +*.spc *.xml !index.html -- cgit v1.2.3