A free, self-hostable news aggregator…
SimplePie: cache feeds with errors
Alexandre Alapetite00127f07c5fc
diff --git a/app/Models/Feed.php b/app/Models/Feed.phpindex 03baf3ad2..bd1babeea 100644--- a/app/Models/Feed.php+++ b/app/Models/Feed.php@@ -217,7 +217,8 @@ class FreshRSS_Feed extends Minz_Model {$mtime = $feed->init();if ((!$mtime) || $feed->error()) {- throw new FreshRSS_Feed_Exception($feed->error() . ' [' . $url . ']');+ $errorMessage = $feed->error();+ throw new FreshRSS_Feed_Exception(($errorMessage == '' ? 'Feed error' : $errorMessage) . ' [' . $url . ']');}if ($loadDetails) {diff --git a/lib/SimplePie/SimplePie.php b/lib/SimplePie/SimplePie.phpindex 06c100f59..84001dd9a 100644--- a/lib/SimplePie/SimplePie.php+++ b/lib/SimplePie/SimplePie.php@@ -1455,7 +1455,11 @@ class SimplePie{// Load the Cache$this->data = $cache->load();- if (!empty($this->data))+ if ($cache->mtime() + $this->cache_duration > time()) { //FreshRSS+ $this->raw_data = false;+ return true; // If the cache is still valid, just return true+ }+ elseif (!empty($this->data)){// If the cache is for an outdated build of SimplePieif (!isset($this->data['build']) || $this->data['build'] !== SIMPLEPIE_BUILD)@@ -1487,7 +1491,7 @@ class SimplePie}}// Check if the cache has been updated- elseif ($cache->mtime() + $this->cache_duration < time())+ else //if ($cache->mtime() + $this->cache_duration < time()) //FreshRSS removed{// If we have last-modified and/or etag set//if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag'])) //FreshRSS removed@@ -1516,6 +1520,7 @@ class SimplePie}else{+ $cache->touch(); //FreshRSS$this->error = $file->error; //FreshRSSreturn !empty($this->data); //FreshRSS//unset($file); //FreshRSS removed@@ -1533,17 +1538,18 @@ class SimplePie}}}- // If the cache is still valid, just return true- else- {- $this->raw_data = false;- return true;- }+ //// If the cache is still valid, just return true+ //else //FreshRSS removed+ //{+ // $this->raw_data = false;+ // return true;+ //}}// If the cache is empty, delete itelse{- $cache->unlink();+ //$cache->unlink(); //FreshRSS removed+ $cache->touch(); //FreshRSS$this->data = array();}}diff --git a/lib/SimplePie/SimplePie/Cache/File.php b/lib/SimplePie/SimplePie/Cache/File.phpindex 3b163545b..cb4b528c4 100644--- a/lib/SimplePie/SimplePie/Cache/File.php+++ b/lib/SimplePie/SimplePie/Cache/File.php@@ -136,11 +136,11 @@ class SimplePie_Cache_File implements SimplePie_Cache_Base*/public function mtime(){- if (file_exists($this->name))+ //if (file_exists($this->name)) //FreshRSS removed{- return filemtime($this->name);+ return @filemtime($this->name); //FreshRSS}- return false;+ //return false; //FreshRSS removed}/**@@ -150,11 +150,11 @@ class SimplePie_Cache_File implements SimplePie_Cache_Base*/public function touch(){- if (file_exists($this->name))+ //if (file_exists($this->name)) //FreshRSS removed{- return touch($this->name);+ return @touch($this->name); //FreshRSS}- return false;+ //return false; //FreshRSS removed}/**