purge_feed: add more debugging output
This commit is contained in:
parent
9b7338e807
commit
f05f9b4252
|
@ -2104,12 +2104,10 @@ class Feeds extends Handler_Protected {
|
||||||
/**
|
/**
|
||||||
* Purge a feed old posts.
|
* Purge a feed old posts.
|
||||||
*
|
*
|
||||||
* @param mixed $link A database connection.
|
|
||||||
* @param mixed $feed_id The id of the purged feed.
|
* @param mixed $feed_id The id of the purged feed.
|
||||||
* @param mixed $purge_interval Olderness of purged posts.
|
* @param mixed $purge_interval Olderness of purged posts.
|
||||||
* @param boolean $debug Set to True to enable the debug. False by default.
|
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
static function purge_feed($feed_id, $purge_interval) {
|
static function purge_feed($feed_id, $purge_interval) {
|
||||||
|
|
||||||
|
@ -2117,27 +2115,30 @@ class Feeds extends Handler_Protected {
|
||||||
|
|
||||||
$pdo = Db::pdo();
|
$pdo = Db::pdo();
|
||||||
|
|
||||||
|
$owner_uid = false;
|
||||||
|
$rows_deleted = 0;
|
||||||
|
|
||||||
$sth = $pdo->prepare("SELECT owner_uid FROM ttrss_feeds WHERE id = ?");
|
$sth = $pdo->prepare("SELECT owner_uid FROM ttrss_feeds WHERE id = ?");
|
||||||
$sth->execute([$feed_id]);
|
$sth->execute([$feed_id]);
|
||||||
|
|
||||||
$owner_uid = false;
|
|
||||||
|
|
||||||
if ($row = $sth->fetch()) {
|
if ($row = $sth->fetch()) {
|
||||||
$owner_uid = $row["owner_uid"];
|
$owner_uid = $row["owner_uid"];
|
||||||
}
|
|
||||||
|
|
||||||
if ($purge_interval == -1 || !$purge_interval) {
|
if (FORCE_ARTICLE_PURGE != 0) {
|
||||||
return;
|
Debug::log("purge_feed: FORCE_ARTICLE_PURGE is set, overriding interval to " . FORCE_ARTICLE_PURGE);
|
||||||
}
|
|
||||||
|
|
||||||
if (!$owner_uid) return;
|
|
||||||
|
|
||||||
if (FORCE_ARTICLE_PURGE == 0) {
|
|
||||||
$purge_unread = get_pref("PURGE_UNREAD_ARTICLES",
|
|
||||||
$owner_uid, false);
|
|
||||||
} else {
|
|
||||||
$purge_unread = true;
|
$purge_unread = true;
|
||||||
$purge_interval = FORCE_ARTICLE_PURGE;
|
$purge_interval = FORCE_ARTICLE_PURGE;
|
||||||
|
} else {
|
||||||
|
$purge_unread = get_pref("PURGE_UNREAD_ARTICLES", $owner_uid, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
$purge_interval = (int) $purge_interval;
|
||||||
|
|
||||||
|
Debug::log("purge_feed: interval $purge_interval days for feed $feed_id, owner: $owner_uid, purge unread: $purge_unread");
|
||||||
|
|
||||||
|
if ($purge_interval <= 0) {
|
||||||
|
Debug::log("purge_feed: purging disabled for this feed, nothing to do.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$purge_unread)
|
if (!$purge_unread)
|
||||||
|
@ -2145,8 +2146,6 @@ class Feeds extends Handler_Protected {
|
||||||
else
|
else
|
||||||
$query_limit = "";
|
$query_limit = "";
|
||||||
|
|
||||||
$purge_interval = (int) $purge_interval;
|
|
||||||
|
|
||||||
if (DB_TYPE == "pgsql") {
|
if (DB_TYPE == "pgsql") {
|
||||||
$sth = $pdo->prepare("DELETE FROM ttrss_user_entries
|
$sth = $pdo->prepare("DELETE FROM ttrss_user_entries
|
||||||
USING ttrss_entries
|
USING ttrss_entries
|
||||||
|
@ -2169,11 +2168,15 @@ class Feeds extends Handler_Protected {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows = $sth->rowCount();
|
$rows_deleted = $sth->rowCount();
|
||||||
|
|
||||||
Debug::log("Purged feed $feed_id ($purge_interval): deleted $rows articles");
|
Debug::log("purge_feed: processed $feed_id: deleted $rows_deleted articles");
|
||||||
|
|
||||||
return $rows;
|
} else {
|
||||||
|
Debug::log("purge_feed: owner of $feed_id not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rows_deleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function feed_purge_interval($feed_id) {
|
static function feed_purge_interval($feed_id) {
|
||||||
|
@ -2188,11 +2191,10 @@ class Feeds extends Handler_Protected {
|
||||||
$purge_interval = $row["purge_interval"];
|
$purge_interval = $row["purge_interval"];
|
||||||
$owner_uid = $row["owner_uid"];
|
$owner_uid = $row["owner_uid"];
|
||||||
|
|
||||||
if ($purge_interval == 0) $purge_interval = get_pref(
|
if ($purge_interval == 0)
|
||||||
'PURGE_OLD_DAYS', $owner_uid);
|
$purge_interval = get_pref('PURGE_OLD_DAYS', $owner_uid, false);
|
||||||
|
|
||||||
return $purge_interval;
|
return $purge_interval;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue