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