From cf8ee6bd48221e73b515922e75945e9aa763f907 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 1 Feb 2014 14:04:37 +0100 Subject: Rafraîchissement des flux en cache super rapide MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contribue à https://github.com/marienfressinaud/FreshRSS/issues/351#issuecomment-31755012 Les flux non-modifiés et en cache ne coûtent maintenant presque plus rien (304, ou délai de cache SimplePie non expiré), alors qu'avant toutes les entrées étaient rechargées --- lib/SimplePie/SimplePie.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'lib/SimplePie/SimplePie.php') diff --git a/lib/SimplePie/SimplePie.php b/lib/SimplePie/SimplePie.php index f02037c10..97b9310db 100644 --- a/lib/SimplePie/SimplePie.php +++ b/lib/SimplePie/SimplePie.php @@ -402,6 +402,9 @@ 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 /** @@ -1226,7 +1229,7 @@ class SimplePie // Check absolute bare minimum requirements. if (!extension_loaded('xml') || !extension_loaded('pcre')) { - return false; + return SIMPLEPIE_INIT_FAIL; } // 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')) @@ -1241,7 +1244,7 @@ class SimplePie } if (!$xml_is_sane) { - return false; + return SIMPLEPIE_INIT_FAIL; } } @@ -1273,11 +1276,11 @@ class SimplePie } $i++; } - return (bool) $success; + return inval($success); } elseif ($this->feed_url === null && $this->raw_data === null) { - return false; + return SIMPLEPIE_INIT_FAIL; } $this->error = null; @@ -1298,10 +1301,10 @@ class SimplePie // Fetch the data via SimplePie_File into $this->raw_data if (($fetched = $this->fetch_data($cache)) === true) { - return true; + return SIMPLEPIE_INIT_CACHE; } elseif ($fetched === false) { - return false; + return SIMPLEPIE_INIT_FAIL; } list($headers, $sniffed) = $fetched; @@ -1378,7 +1381,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 false; + return SIMPLEPIE_INIT_FAIL; } if (isset($headers)) @@ -1392,7 +1395,7 @@ class SimplePie { 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 true; + return SIMPLEPIE_INIT_SUCCESS; } } } @@ -1409,7 +1412,7 @@ class SimplePie $this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__)); - return false; + return SIMPLEPIE_INIT_FAIL; } /** -- cgit v1.2.3