X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWorker%2FUpdateGServers.php;h=108482eaecef4035336e8b1c7797c3f8ddacde29;hb=0e82f64d71b598a1349ac22973148715f7182fdd;hp=12022a34682f47cc831f1bbdb68e4b04578a9b32;hpb=edbdfbae6b78086c220c0ad116c0fa7deb03a6e8;p=friendica.git diff --git a/src/Worker/UpdateGServers.php b/src/Worker/UpdateGServers.php index 12022a3468..108482eaec 100644 --- a/src/Worker/UpdateGServers.php +++ b/src/Worker/UpdateGServers.php @@ -1,6 +1,6 @@ get('system', 'gserver_update_limit'); + if (empty($update_limit)) { + return; + } + $updating = Worker::countWorkersByCommand('UpdateGServer'); - $limit = 100 - $updating; + $limit = $update_limit - $updating; if ($limit <= 0) { Logger::info('The number of currently running jobs exceed the limit'); return; } - $outdated = DBA::count('gserver', ["`next_contact` < UTC_TIMESTAMP()"]); $total = DBA::count('gserver'); + $condition = ["`next_contact` < ? AND (`nurl` != ? OR `url` != ?)", DateTimeFormat::utcNow(), '', '']; + $outdated = DBA::count('gserver', $condition); Logger::info('Server status', ['total' => $total, 'outdated' => $outdated, 'updating' => $limit]); - $gservers = DBA::select('gserver', ['url'], ["`next_contact` < UTC_TIMESTAMP()"], ['limit' => $limit]); + $gservers = DBA::select('gserver', ['url', 'nurl'], $condition, ['limit' => $limit]); if (!DBA::isResult($gservers)) { return; } $count = 0; while ($gserver = DBA::fetch($gservers)) { - Worker::add(PRIORITY_LOW, 'UpdateGServer', $gserver['url'], false, true); - $count++; + // Sometimes the "nurl" and "url" doesn't seem to fit, see https://forum.friendi.ca/display/ec054ce7-155f-c94d-6159-f50372664245 + // There are duplicated "url" but not "nurl". So we check both addresses instead of just overwriting them, + // since that would mean loosing data. + if (!empty($gserver['url'])) { + if (Worker::add(PRIORITY_LOW, 'UpdateGServer', $gserver['url'])) { + $count++; + } + } + if (!empty($gserver['nurl']) && ($gserver['nurl'] != Strings::normaliseLink($gserver['url']))) { + if (Worker::add(PRIORITY_LOW, 'UpdateGServer', $gserver['nurl'])) { + $count++; + } + } + Worker::coolDown(); } DBA::close($gservers); Logger::info('Updated servers', ['count' => $count]);