|
|
@@ -18,7 +18,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
|
|
ttl
|
|
|
)
|
|
|
VALUES
|
|
|
- (?, ?, ?, ?, ?, ?, 10, ?, 0, -2, -2)';
|
|
|
+ (?, ?, ?, ?, ?, ?, 10, ?, 0, -2, ?)';
|
|
|
$stm = $this->bd->prepare($sql);
|
|
|
|
|
|
$valuesTmp['url'] = safe_ascii($valuesTmp['url']);
|
|
|
@@ -32,6 +32,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
|
|
substr($valuesTmp['description'], 0, 1023),
|
|
|
$valuesTmp['lastUpdate'],
|
|
|
base64_encode($valuesTmp['httpAuth']),
|
|
|
+ FreshRSS_Feed::TTL_DEFAULT,
|
|
|
);
|
|
|
|
|
|
if ($stm && $stm->execute($values)) {
|
|
|
@@ -249,18 +250,14 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
|
|
* Use $defaultCacheDuration == -1 to return all feeds, without filtering them by TTL.
|
|
|
*/
|
|
|
public function listFeedsOrderUpdate($defaultCacheDuration = 3600) {
|
|
|
+ $this->updateTTL();
|
|
|
$sql = 'SELECT id, url, name, website, `lastUpdate`, `pathEntries`, `httpAuth`, keep_history, ttl '
|
|
|
. 'FROM `' . $this->prefix . 'feed` '
|
|
|
- . ($defaultCacheDuration < 0 ? '' : 'WHERE ttl <> -1 AND `lastUpdate` < (' . (time() + 60) . '-(CASE WHEN ttl=-2 THEN ' . intval($defaultCacheDuration) . ' ELSE ttl END)) ')
|
|
|
+ . ($defaultCacheDuration < 0 ? '' : 'WHERE ttl >= ' . FreshRSS_Feed::TTL_DEFAULT
|
|
|
+ . ' AND `lastUpdate` < (' . (time() + 60) . '-(CASE WHEN ttl=' . FreshRSS_Feed::TTL_DEFAULT . ' THEN ' . intval($defaultCacheDuration) . ' ELSE ttl END)) ')
|
|
|
. 'ORDER BY `lastUpdate`';
|
|
|
$stm = $this->bd->prepare($sql);
|
|
|
- if (!($stm && $stm->execute())) {
|
|
|
- $sql2 = 'ALTER TABLE `' . $this->prefix . 'feed` ADD COLUMN ttl INT NOT NULL DEFAULT -2'; //v0.7.3
|
|
|
- $stm = $this->bd->prepare($sql2);
|
|
|
- $stm->execute();
|
|
|
- $stm = $this->bd->prepare($sql);
|
|
|
- $stm->execute();
|
|
|
- }
|
|
|
+ $stm->execute();
|
|
|
|
|
|
return self::daoToFeed($stm->fetchAll(PDO::FETCH_ASSOC));
|
|
|
}
|
|
|
@@ -410,7 +407,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
|
|
$myFeed->_httpAuth(isset($dao['httpAuth']) ? base64_decode($dao['httpAuth']) : '');
|
|
|
$myFeed->_error(isset($dao['error']) ? $dao['error'] : 0);
|
|
|
$myFeed->_keepHistory(isset($dao['keep_history']) ? $dao['keep_history'] : -2);
|
|
|
- $myFeed->_ttl(isset($dao['ttl']) ? $dao['ttl'] : -2);
|
|
|
+ $myFeed->_ttl(isset($dao['ttl']) ? $dao['ttl'] : FreshRSS_Feed::TTL_DEFAULT);
|
|
|
$myFeed->_nbNotRead(isset($dao['cache_nbUnreads']) ? $dao['cache_nbUnreads'] : 0);
|
|
|
$myFeed->_nbEntries(isset($dao['cache_nbEntries']) ? $dao['cache_nbEntries'] : 0);
|
|
|
if (isset($dao['id'])) {
|
|
|
@@ -421,4 +418,20 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
|
|
|
|
|
|
return $list;
|
|
|
}
|
|
|
+
|
|
|
+ public function updateTTL() {
|
|
|
+ $sql = <<<SQL
|
|
|
+UPDATE `{$this->prefix}feed`
|
|
|
+ SET ttl = :new_value
|
|
|
+ WHERE ttl = :old_value
|
|
|
+SQL;
|
|
|
+ $stm = $this->bd->prepare($sql);
|
|
|
+ if (!($stm && $stm->execute(array(':new_value' => FreshRSS_Feed::TTL_DEFAULT, ':old_value' => -2)))) {
|
|
|
+ $sql2 = 'ALTER TABLE `' . $this->prefix . 'feed` ADD COLUMN ttl INT NOT NULL DEFAULT ' . FreshRSS_Feed::TTL_DEFAULT; //v0.7.3
|
|
|
+ $stm = $this->bd->prepare($sql2);
|
|
|
+ $stm->execute();
|
|
|
+ } else {
|
|
|
+ $stm->execute(array(':new_value' => -3600, ':old_value' => -1));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|