mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-05-24 08:14:56 -04:00
Rafraîchissement des flux en cache compatible multi-utilisateurs
Compatibilité multi-utilisateurs pour la mise à jour rapide des flux
avec cache
Correction de
cf8ee6bd48 (commitcomment-5247478)
Contribue à
https://github.com/marienfressinaud/FreshRSS/issues/351#issuecomment-31755012
This commit is contained in:
@@ -193,9 +193,9 @@ class FreshRSS_Feed extends Minz_Model {
|
||||
}
|
||||
$feed = customSimplePie();
|
||||
$feed->set_feed_url ($url);
|
||||
$initResult = $feed->init ();
|
||||
$mtime = $feed->init();
|
||||
|
||||
if ((!$initResult) || $feed->error()) {
|
||||
if ((!$mtime) || $feed->error()) {
|
||||
throw new FreshRSS_Feed_Exception ($feed->error() . ' [' . $url . ']');
|
||||
}
|
||||
|
||||
@@ -217,9 +217,11 @@ class FreshRSS_Feed extends Minz_Model {
|
||||
$this->_description(html_only_entity_decode($feed->get_description()));
|
||||
}
|
||||
|
||||
if (($initResult == SIMPLEPIE_INIT_SUCCESS) || $loadDetails) {
|
||||
if (($mtime === true) || ($mtime > $this->lastUpdate)) {
|
||||
syslog(LOG_DEBUG, 'FreshRSS no cache ' . $mtime . ' > ' . $this->lastUpdate);
|
||||
$this->loadEntries($feed); // et on charge les articles du flux
|
||||
} else {
|
||||
syslog(LOG_DEBUG, 'FreshRSS use cache for ' . $subscribe_url);
|
||||
$this->entries = array();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {
|
||||
}
|
||||
|
||||
public function listFeedsOrderUpdate () {
|
||||
$sql = 'SELECT id, name, url, pathEntries, httpAuth, keep_history FROM `' . $this->prefix . 'feed` ORDER BY lastUpdate';
|
||||
$sql = 'SELECT id, name, url, lastUpdate, pathEntries, httpAuth, keep_history FROM `' . $this->prefix . 'feed` ORDER BY lastUpdate';
|
||||
$stm = $this->bd->prepare ($sql);
|
||||
$stm->execute ();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -2161,36 +2161,12 @@ function embed_wmedia(width, height, link) {
|
||||
/**
|
||||
* Get the SimplePie build timestamp
|
||||
*
|
||||
* Uses the git index if it exists, otherwise uses the modification time
|
||||
* of the newest file.
|
||||
* Return SimplePie.php modification time.
|
||||
*/
|
||||
public static function get_build()
|
||||
{
|
||||
$root = dirname(dirname(__FILE__));
|
||||
if (file_exists($root . '/.git/index'))
|
||||
{
|
||||
return filemtime($root . '/.git/index');
|
||||
}
|
||||
elseif (file_exists($root . '/SimplePie'))
|
||||
{
|
||||
$time = 0;
|
||||
foreach (glob($root . '/SimplePie/*.php') as $file)
|
||||
{
|
||||
if (($mtime = filemtime($file)) > $time)
|
||||
{
|
||||
$time = $mtime;
|
||||
}
|
||||
}
|
||||
return $time;
|
||||
}
|
||||
elseif (file_exists(dirname(__FILE__) . '/Core.php'))
|
||||
{
|
||||
return filemtime(dirname(__FILE__) . '/Core.php');
|
||||
}
|
||||
else
|
||||
{
|
||||
return filemtime(__FILE__);
|
||||
}
|
||||
$mtime = @filemtime(dirname(dirname(__FILE__)) . '/SimplePie.php'); //FreshRSS
|
||||
return $mtime ? $mtime : filemtime(__FILE__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user