A free, self-hostable news aggregator…
Option to force clear cache (#2052)
Alexandre Alapetite0aecf442946f
diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.phpindex 511cea11b..0b1439ba5 100644--- a/app/Controllers/subscriptionController.php+++ b/app/Controllers/subscriptionController.php@@ -98,6 +98,7 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {$feed->_attributes('mark_updated_article_unread', Minz_Request::paramTernary('mark_updated_article_unread'));$feed->_attributes('read_upon_reception', Minz_Request::paramTernary('read_upon_reception'));+ $feed->_attributes('clear_cache', Minz_Request::paramTernary('clear_cache'));if (FreshRSS_Auth::hasAccess('admin')) {$feed->_attributes('ssl_verify', Minz_Request::paramTernary('ssl_verify'));diff --git a/app/Models/Feed.php b/app/Models/Feed.phpindex 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() {diff --git a/app/i18n/cz/sub.php b/app/i18n/cz/sub.phpindex 5caf9acbe..55441aaf8 100644--- a/app/i18n/cz/sub.php+++ b/app/i18n/cz/sub.php@@ -27,6 +27,7 @@ return array('password' => 'Heslo','username' => 'Přihlašovací jméno',),+ 'clear_cache' => 'Always clear cache', //TODO'css_help' => 'Stáhne zkrácenou verzi RSS kanálů (pozor, náročnější na čas!)','css_path' => 'Původní CSS soubor článku z webových stránek','description' => 'Popis',diff --git a/app/i18n/de/sub.php b/app/i18n/de/sub.phpindex 0ba818c69..ff5c11d2b 100644--- a/app/i18n/de/sub.php+++ b/app/i18n/de/sub.php@@ -27,6 +27,7 @@ return array('password' => 'HTTP-Passwort','username' => 'HTTP-Nutzername',),+ 'clear_cache' => 'Always clear cache', //TODO'css_help' => 'Ruft gekürzte RSS-Feeds ab (Achtung, benötigt mehr Zeit!)','css_path' => 'Pfad zur CSS-Datei des Artikels auf der Original-Webseite','description' => 'Beschreibung',diff --git a/app/i18n/en/sub.php b/app/i18n/en/sub.phpindex 5ff41a4b3..22c7edc30 100644--- a/app/i18n/en/sub.php+++ b/app/i18n/en/sub.php@@ -27,6 +27,7 @@ return array('password' => 'HTTP password','username' => 'HTTP username',),+ 'clear_cache' => 'Always clear cache','css_help' => 'Retrieves truncated RSS feeds (caution, requires more time!)','css_path' => 'Articles CSS path on original website','description' => 'Description',diff --git a/app/i18n/es/sub.php b/app/i18n/es/sub.phpindex 3abc85578..8a4fb98de 100755--- a/app/i18n/es/sub.php+++ b/app/i18n/es/sub.php@@ -22,6 +22,7 @@ return array('password' => 'Contraseña HTTP','username' => 'Nombre de usuario HTTP',),+ 'clear_cache' => 'Always clear cache', //TODO'css_help' => 'Recibir fuentes RSS truncadas (aviso, ¡necesita más tiempo!)','css_path' => 'Ruta a la CSS de los artículos en la web original','description' => 'Descripción',diff --git a/app/i18n/fr/sub.php b/app/i18n/fr/sub.phpindex c6af2fb90..d3921f1d9 100644--- a/app/i18n/fr/sub.php+++ b/app/i18n/fr/sub.php@@ -27,6 +27,7 @@ return array('password' => 'Mot de passe HTTP','username' => 'Identifiant HTTP',),+ 'clear_cache' => 'Toujours vider le cache','css_help' => 'Permet de récupérer les flux tronqués (attention, demande plus de temps !)','css_path' => 'Sélecteur CSS des articles sur le site d’origine','description' => 'Description',diff --git a/app/i18n/he/sub.php b/app/i18n/he/sub.phpindex a263cd728..711004662 100644--- a/app/i18n/he/sub.php+++ b/app/i18n/he/sub.php@@ -27,6 +27,7 @@ return array('password' => 'HTTP סיסמה','username' => 'HTTP שם משתמש',),+ 'clear_cache' => 'Always clear cache', //TODO'css_help' => 'קבלת הזנות RSS קטומות (זהירות, לוקח זמן רב יותר!)','css_path' => 'נתיב הCSS של המאמר באתר המקורי','description' => 'תיאור',diff --git a/app/i18n/it/sub.php b/app/i18n/it/sub.phpindex 22d58a27f..b22340c9b 100644--- a/app/i18n/it/sub.php+++ b/app/i18n/it/sub.php@@ -27,6 +27,7 @@ return array('password' => 'HTTP password','username' => 'HTTP username',),+ 'clear_cache' => 'Always clear cache', //TODO'css_help' => 'In caso di RSS feeds troncati (attenzione, richiede molto tempo!)','css_path' => 'Percorso del foglio di stile CSS del sito di origine','description' => 'Descrizione',diff --git a/app/i18n/kr/sub.php b/app/i18n/kr/sub.phpindex de200c330..ee6b25e3f 100644--- a/app/i18n/kr/sub.php+++ b/app/i18n/kr/sub.php@@ -27,6 +27,7 @@ return array('password' => 'HTTP 암호','username' => 'HTTP 사용자 이름',),+ 'clear_cache' => 'Always clear cache', //TODO'css_help' => '글의 일부가 포함된 RSS 피드를 가져옵니다 (주의, 시간이 좀 더 걸립니다!)','css_path' => '웹사이트 상의 글 본문에 해당하는 CSS 경로','description' => '설명',diff --git a/app/i18n/nl/sub.php b/app/i18n/nl/sub.phpindex 4ce254ef5..fec7fb4e7 100644--- a/app/i18n/nl/sub.php+++ b/app/i18n/nl/sub.php@@ -27,6 +27,7 @@ return array('password' => 'HTTP wachtwoord','username' => 'HTTP gebruikers naam',),+ 'clear_cache' => 'Always clear cache', //TODO'css_help' => 'Haalt verstoorde RSS feeds op (attentie, heeft meer tijd nodig!)','css_path' => 'Artikelen CSS pad op originele website','description' => 'Omschrijving',diff --git a/app/i18n/pt-br/sub.php b/app/i18n/pt-br/sub.phpindex 1b084f08f..daa24e8f3 100644--- a/app/i18n/pt-br/sub.php+++ b/app/i18n/pt-br/sub.php@@ -27,6 +27,7 @@ return array('password' => 'Senha HTTP','username' => 'Usuário HTTP',),+ 'clear_cache' => 'Always clear cache', //TODO'css_help' => 'Retorna RSS feeds truncados (atenção, requer mais tempo!)','css_path' => 'Caminho do CSS do artigo no site original','description' => 'Descrição',diff --git a/app/i18n/ru/sub.php b/app/i18n/ru/sub.phpindex bef49623f..12901998d 100644--- a/app/i18n/ru/sub.php+++ b/app/i18n/ru/sub.php@@ -27,6 +27,7 @@ return array('password' => 'HTTP password',// TODO'username' => 'HTTP username',// TODO),+ 'clear_cache' => 'Always clear cache', //TODO'css_help' => 'Retrieves truncated RSS feeds (caution, requires more time!)',// TODO'css_path' => 'Articles CSS path on original website',// TODO'description' => 'Description',// TODOdiff --git a/app/i18n/tr/sub.php b/app/i18n/tr/sub.phpindex e8cd15d0d..ef0c8ffbd 100644--- a/app/i18n/tr/sub.php+++ b/app/i18n/tr/sub.php@@ -27,6 +27,7 @@ return array('password' => 'HTTP şifre','username' => 'HTTP kullanıcı adı',),+ 'clear_cache' => 'Always clear cache', //TODO'css_help' => 'Dikkat, daha çok zaman gerekir!','css_path' => 'Makaleleri kendi CSS görünümü ile göster','description' => 'Tanım',diff --git a/app/i18n/zh-cn/sub.php b/app/i18n/zh-cn/sub.phpindex 034f8a9d9..4980b803a 100644--- a/app/i18n/zh-cn/sub.php+++ b/app/i18n/zh-cn/sub.php@@ -27,6 +27,7 @@ return array('password' => 'HTTP 密码','username' => 'HTTP 用户名',),+ 'clear_cache' => 'Always clear cache', //TODO'css_help' => '用于获取全文(注意,这将耗费更多时间!)','css_path' => '原文的 CSS 选择器','description' => '描述',diff --git a/app/views/helpers/feed/update.phtml b/app/views/helpers/feed/update.phtmlindex 7144aab46..4dbaacd04 100644--- a/app/views/helpers/feed/update.phtml+++ b/app/views/helpers/feed/update.phtml@@ -205,6 +205,13 @@</div></div>+ <div class="form-group">+ <label class="group-name" for="clear_cache"><?php echo _t('sub.feed.clear_cache'); ?></label>+ <div class="group-controls">+ <input type="checkbox" name="clear_cache" id="clear_cache" value="1"<?php echo $this->feed->attributes('clear_cache') ? ' checked="checked"' : ''; ?> />+ </div>+ </div>+<?php if (FreshRSS_Auth::hasAccess('admin')) { ?><div class="form-group"><label class="group-name" for="timeout"><?php echo _t('sub.feed.timeout'); ?></label>