aboutsummaryrefslogtreecommitdiff
path: root/app/Models/Feed.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2018-10-17 18:03:50 +0200
committerGravatar GitHub <noreply@github.com> 2018-10-17 18:03:50 +0200
commit0aecf442946f7aa618fcc759f79807cd81346dc4 (patch)
tree403faeff60c72f61299eba66f2f1701d92be9060 /app/Models/Feed.php
parentdfff5f21886ed023962aa8087a11222fe3c3f995 (diff)
Option to force clear cache (#2052)
https://github.com/FreshRSS/FreshRSS/issues/1020#issuecomment-428515868
Diffstat (limited to 'app/Models/Feed.php')
-rw-r--r--app/Models/Feed.php14
1 files changed, 13 insertions, 1 deletions
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() {