From 0aecf442946f7aa618fcc759f79807cd81346dc4 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 17 Oct 2018 18:03:50 +0200 Subject: Option to force clear cache (#2052) https://github.com/FreshRSS/FreshRSS/issues/1020#issuecomment-428515868 --- app/Models/Feed.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'app/Models/Feed.php') diff --git a/app/Models/Feed.php b/app/Models/Feed.php index d09577e6e..e1dd2990d 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -286,6 +286,10 @@ class FreshRSS_Feed extends Minz_Model { if (!$loadDetails) { //Only activates auto-discovery when adding a new feed $feed->set_autodiscovery_level(SIMPLEPIE_LOCATOR_NONE); } + if ($this->attributes('clear_cache')) { + // Do not use `$simplePie->enable_cache(false);` as it would prevent caching in multiuser context + $this->clearCache(); + } Minz_ExtensionManager::callHook('simplepie_before_init', $feed, $this); $mtime = $feed->init(); @@ -465,8 +469,16 @@ class FreshRSS_Feed extends Minz_Model { $this->entries = $entries; } + protected function cacheFilename() { + return CACHE_PATH . '/' . md5($this->url) . '.spc'; + } + + public function clearCache() { + return @unlink($this->cacheFilename()); + } + public function cacheModifiedTime() { - return @filemtime(CACHE_PATH . '/' . md5($this->url) . '.spc'); + return @filemtime($this->cacheFilename()); } public function lock() { -- cgit v1.2.3