diff options
| author | 2014-02-01 20:13:42 +0100 | |
|---|---|---|
| committer | 2014-02-01 20:13:42 +0100 | |
| commit | 02d1dac0bb07884b79ddea20980bfcf21131f2d7 (patch) | |
| tree | 1c004e5bbaf9cab501076547596f007906c46be0 /lib/SimplePie/SimplePie.php | |
| parent | a76e5bd1c65354dbdc9793179369ef0903d03762 (diff) | |
Rafraîchissement des flux en cache compatible multi-utilisateurs
Compatibilité multi-utilisateurs pour la mise à jour rapide des flux
avec cache
Correction de
https://github.com/marienfressinaud/FreshRSS/commit/cf8ee6bd48221e73b515922e75945e9aa763f907#commitcomment-5247478
Contribue à
https://github.com/marienfressinaud/FreshRSS/issues/351#issuecomment-31755012
Diffstat (limited to 'lib/SimplePie/SimplePie.php')
| -rw-r--r-- | lib/SimplePie/SimplePie.php | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/SimplePie/SimplePie.php b/lib/SimplePie/SimplePie.php index 97b9310db..fe01d382e 100644 --- a/lib/SimplePie/SimplePie.php +++ b/lib/SimplePie/SimplePie.php @@ -402,9 +402,6 @@ define('SIMPLEPIE_FILE_SOURCE_CURL', 8); */ define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16); -define('SIMPLEPIE_INIT_FAIL', 0); //FreshRSS -define('SIMPLEPIE_INIT_SUCCESS', 1); //FreshRSS -define('SIMPLEPIE_INIT_CACHE', 2); //FreshRSS /** @@ -1222,14 +1219,14 @@ class SimplePie * configuration options get processed, feeds are fetched, cached, and * parsed, and all of that other good stuff. * - * @return boolean True if successful, false otherwise + * @return positive integer with modification time if using cache, boolean true if otherwise successful, false otherwise */ public function init() { // Check absolute bare minimum requirements. if (!extension_loaded('xml') || !extension_loaded('pcre')) { - return SIMPLEPIE_INIT_FAIL; + return false; } // Then check the xml extension is sane (i.e., libxml 2.7.x issue on PHP < 5.2.9 and libxml 2.7.0 to 2.7.2 on any version) if we don't have xmlreader. elseif (!extension_loaded('xmlreader')) @@ -1244,7 +1241,7 @@ class SimplePie } if (!$xml_is_sane) { - return SIMPLEPIE_INIT_FAIL; + return false; } } @@ -1276,11 +1273,11 @@ class SimplePie } $i++; } - return inval($success); + return (bool) $success; } elseif ($this->feed_url === null && $this->raw_data === null) { - return SIMPLEPIE_INIT_FAIL; + return false; } $this->error = null; @@ -1301,10 +1298,10 @@ class SimplePie // Fetch the data via SimplePie_File into $this->raw_data if (($fetched = $this->fetch_data($cache)) === true) { - return SIMPLEPIE_INIT_CACHE; + return $this->data['mtime']; //FreshRSS } elseif ($fetched === false) { - return SIMPLEPIE_INIT_FAIL; + return false; } list($headers, $sniffed) = $fetched; @@ -1381,7 +1378,7 @@ class SimplePie { $this->error = "A feed could not be found at $this->feed_url. This does not appear to be a valid RSS or Atom feed."; $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); - return SIMPLEPIE_INIT_FAIL; + return false; } if (isset($headers)) @@ -1389,13 +1386,14 @@ class SimplePie $this->data['headers'] = $headers; } $this->data['build'] = SIMPLEPIE_BUILD; + $this->data['mtime'] = time(); //FreshRSS // Cache the file if caching is enabled if ($cache && !$cache->save($this)) { trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); } - return SIMPLEPIE_INIT_SUCCESS; + return true; } } } @@ -1412,7 +1410,7 @@ class SimplePie $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); - return SIMPLEPIE_INIT_FAIL; + return false; } /** @@ -1558,6 +1556,7 @@ class SimplePie if ($cache) { $this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD); + $this->data['mtime'] = time(); //FreshRSS if (!$cache->save($this)) { trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING); |
