Handle stream error in spoolnews.php to avoid skipping groups.
This commit is contained in:
parent
59c81f14d4
commit
8231373c80
|
@ -296,12 +296,23 @@ function thread_mycompare($a, $b)
|
||||||
function thread_load_newsserver(&$ns, $groupname, $poll)
|
function thread_load_newsserver(&$ns, $groupname, $poll)
|
||||||
{
|
{
|
||||||
global $spooldir, $logdir, $maxarticles, $maxfetch, $initialfetch, $maxarticles_extra, $config_name;
|
global $spooldir, $logdir, $maxarticles, $maxfetch, $initialfetch, $maxarticles_extra, $config_name;
|
||||||
global $text_error, $text_thread, $compress_spoolfiles, $server;
|
global $text_error, $text_thread, $compress_spoolfiles, $server, $CONFIG;
|
||||||
global $www_charset, $iconv_enable, $thread_show, $thread_sort_order;
|
global $www_charset, $iconv_enable, $thread_show, $thread_sort_order;
|
||||||
$logfile = $logdir . '/newsportal.log';
|
$logfile = $logdir . '/newsportal.log';
|
||||||
$maxfetch = 0;
|
$maxfetch = 0;
|
||||||
$idstring = "0.36," . $server . "," . $compress_spoolfiles . "," . $maxarticles . "," . $maxarticles_extra . "," . $maxfetch . "," . $initialfetch . "," . $www_charset . ',' . $iconv_enable . ',' . $thread_show["replies"];
|
$idstring = "0.36," . $server . "," . $compress_spoolfiles . "," . $maxarticles . "," . $maxarticles_extra . "," . $maxfetch . "," . $initialfetch . "," . $www_charset . ',' . $iconv_enable . ',' . $thread_show["replies"];
|
||||||
|
if ($CONFIG['enable_nntp'] == '1') {
|
||||||
|
$overviewfmt = array(
|
||||||
|
"Subject:",
|
||||||
|
"From:",
|
||||||
|
"Date:",
|
||||||
|
"Message-ID:",
|
||||||
|
"References:",
|
||||||
|
"Bytes:"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
$overviewformat = thread_overview_read($ns);
|
$overviewformat = thread_overview_read($ns);
|
||||||
|
}
|
||||||
$spoolfilename = $spooldir . '/' . $groupname . '-data.db3';
|
$spoolfilename = $spooldir . '/' . $groupname . '-data.db3';
|
||||||
fputs($ns, "GROUP $groupname\r\n"); // select a group
|
fputs($ns, "GROUP $groupname\r\n"); // select a group
|
||||||
$groupinfo = explode(" ", line_read($ns));
|
$groupinfo = explode(" ", line_read($ns));
|
||||||
|
|
|
@ -24,6 +24,10 @@ include "config.inc.php";
|
||||||
include ("$file_newsportal");
|
include ("$file_newsportal");
|
||||||
include $config_dir . '/gpg.conf';
|
include $config_dir . '/gpg.conf';
|
||||||
|
|
||||||
|
set_error_handler(function (int $number, string $message) {
|
||||||
|
echo "Handler captured error $number: '$message'" . PHP_EOL;
|
||||||
|
});
|
||||||
|
|
||||||
if ($CONFIG['remote_server'] != '') {
|
if ($CONFIG['remote_server'] != '') {
|
||||||
$remote_groupfile = $spooldir . "/" . $config_name . "/" . $CONFIG['remote_server'] . ":" . $CONFIG['remote_port'] . ".txt";
|
$remote_groupfile = $spooldir . "/" . $config_name . "/" . $CONFIG['remote_server'] . ":" . $CONFIG['remote_port'] . ".txt";
|
||||||
}
|
}
|
||||||
|
@ -139,20 +143,27 @@ if ($CONFIG['remote_server'] != '') {
|
||||||
get_articles($ns, $name[0]);
|
get_articles($ns, $name[0]);
|
||||||
|
|
||||||
if ($enable_rslight == 1) {
|
if ($enable_rslight == 1) {
|
||||||
if (filemtime($spooldir . '/' . $name[0] . '-thread-timer') + 600 < time()) {
|
$timer_file = $spooldir . '/tmp/' . $name[0] . '-thread-timer';
|
||||||
|
if (filemtime($timer_file) + 600 < time()) {
|
||||||
|
touch($timer_file);
|
||||||
if (! $ns2) {
|
if (! $ns2) {
|
||||||
$ns2 = nntp_open();
|
$ns2 = nntp_open();
|
||||||
|
echo "\nOPENING $ns2: " . $ns2 . "\n";
|
||||||
}
|
}
|
||||||
if (! $ns2) {
|
if (! $ns2) {
|
||||||
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Failed to connect to " . $CONFIG['remote_server'] . ":" . $CONFIG['remote_port'], FILE_APPEND);
|
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Failed to connect to " . $CONFIG['remote_server'] . ":" . $CONFIG['remote_port'], FILE_APPEND);
|
||||||
// exit();
|
// exit();
|
||||||
} else {
|
} else {
|
||||||
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Updating threads for: " . $name[0] . "...", FILE_APPEND);
|
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Updating threads for: " . $name[0] . "...", FILE_APPEND);
|
||||||
|
try {
|
||||||
thread_load_newsserver($ns2, $name[0], 0);
|
thread_load_newsserver($ns2, $name[0], 0);
|
||||||
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Threads updated for: " . $name[0], FILE_APPEND);
|
} catch (Exception $exc) {
|
||||||
// nntp_close($ns2);
|
echo "\nFatal exception caught: " . $exc->getMessage();
|
||||||
|
} catch (Error $err) {
|
||||||
|
echo "\nFatal error caught: " . $err->getMessage();
|
||||||
|
}
|
||||||
|
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Threads updated for: " . $name[0], FILE_APPEND);
|
||||||
}
|
}
|
||||||
touch($spooldir . '/' . $name[0] . '-thread-timer');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,7 +251,9 @@ function get_articles($ns, $group)
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pull articles and save them in our spool
|
# Pull articles and save them in our spool
|
||||||
@mkdir($grouppath, 0755, 'recursive');
|
if (! is_dir($grouppath)) {
|
||||||
|
mkdir($grouppath, 0755, 'recursive');
|
||||||
|
}
|
||||||
$i = 0;
|
$i = 0;
|
||||||
// GET INDIVIDUAL ARTICLE
|
// GET INDIVIDUAL ARTICLE
|
||||||
while ($article <= $detail[3]) {
|
while ($article <= $detail[3]) {
|
||||||
|
|
Loading…
Reference in New Issue