X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWorker%2FUpdateContacts.php;h=6fb71eec383fff892fea758f28e99343589372c4;hb=131695cb1167a831dbe87a0f2b1bde755dabd55f;hp=e6469fe19e0a1ae8dca8fbd254334abb7c6ce556;hpb=23cf850198a567c24949ba000613fe749910f9bb;p=friendica.git diff --git a/src/Worker/UpdateContacts.php b/src/Worker/UpdateContacts.php index e6469fe19e..6fb71eec38 100644 --- a/src/Worker/UpdateContacts.php +++ b/src/Worker/UpdateContacts.php @@ -1,6 +1,6 @@ true], $condition); } - $condition = array_merge(["`next-update` < ?", DateTimeFormat::utcNow()], $condition); - $contacts = DBA::select('contact', ['id'], $condition, ['order' => ['next-update'], 'limit' => $limit]); + $condition = DBA::mergeConditions(["`next-update` < ?", DateTimeFormat::utcNow()], $condition); + $contacts = DBA::select('contact', ['id', 'url', 'gsid', 'baseurl'], $condition, ['order' => ['next-update'], 'limit' => $limit]); $count = 0; while ($contact = DBA::fetch($contacts)) { - if (Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], "UpdateContact", $contact['id'])) { - ++$count; + if (Contact::isLocal($contact['url'])) { + continue; } + + try { + if ((!empty($contact['gsid']) || !empty($contact['baseurl'])) && GServer::reachable($contact)) { + $stamp = (float)microtime(true); + $success = Contact::updateFromProbe($contact['id']); + Logger::debug('Direct update', ['id' => $contact['id'], 'count' => $count, 'duration' => round((float)microtime(true) - $stamp, 3), 'success' => $success]); + ++$count; + } elseif (UpdateContact::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], $contact['id'])) { + Logger::debug('Update by worker', ['id' => $contact['id'], 'count' => $count]); + ++$count; + } + } catch (\InvalidArgumentException $e) { + Logger::notice($e->getMessage(), ['contact' => $contact]); + } + + Worker::coolDown(); } DBA::close($contacts);