Remove articles from np database if not available

This commit is contained in:
Retro_Guy 2021-01-27 23:10:32 -07:00
parent 0cca82eb1a
commit efa401bc0e
2 changed files with 8 additions and 1 deletions

View File

@ -244,7 +244,7 @@ function message_read($id,$bodynum=0,$group="") {
fclose($rawmessage_fh);
}
}
if(!isset($rawmessage)) {
if(!isset($rawmessage) || $rawmessage === FALSE) {
file_put_contents($logfile, "\n".format_log_date()." ".$config_name." DEBUG: Requesting: ".$group.":".$id." from server", FILE_APPEND);
if (!isset($ns)) {
$ns=nntp_open();

View File

@ -1321,6 +1321,7 @@ function np_get_db_article($article, $group, $makearray=1, $dbh=null) {
$dbh = article_db_open($database);
$closeme = 1;
}
$ok_article = 0;
// By Message-ID
if(!is_numeric($article)) {
$stmt = $dbh->prepare("SELECT * FROM articles WHERE msgid like :terms");
@ -1328,6 +1329,7 @@ function np_get_db_article($article, $group, $makearray=1, $dbh=null) {
$stmt->execute();
while($found = $stmt->fetch()) {
$msg2 = $found['article'];
$ok_article = 1;
break;
}
} else {
@ -1336,12 +1338,17 @@ function np_get_db_article($article, $group, $makearray=1, $dbh=null) {
$stmt->execute();
while($found = $stmt->fetch()) {
$msg2 = $found['article'];
$ok_article = 1;
break;
}
}
if($closeme == 1) {
$dbh = null;
}
if($ok_article !== 1) {
file_put_contents($logfile, "\n".format_log_date()." ".$config_name." DEBUG: ".$article." from ".$group." not found in database", FILE_APPEND);
return FALSE;
}
file_put_contents($logfile, "\n".format_log_date()." ".$config_name." DEBUG: fetched: ".$article." from ".$group, FILE_APPEND);
if($makearray == 1) {
$thisarticle = preg_split("/\r\n|\n|\r/", trim($msg2));