aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2014-02-01 14:04:37 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2014-02-01 14:04:37 +0100
commitcf8ee6bd48221e73b515922e75945e9aa763f907 (patch)
tree75d86ec2448118fd6e9dc3b6859f5dd8594d9de2 /lib
parent5e9c60752c9a40e1540de50d02e19ba1d06e5491 (diff)
Rafraîchissement des flux en cache super rapide
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
Diffstat (limited to 'lib')
-rw-r--r--lib/SimplePie/SimplePie.php21
1 files changed, 12 insertions, 9 deletions
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;
}
/**