mirror of
https://github.com/friendica/friendica
synced 2025-05-04 17:04:11 +02:00
Ward againt contact_id = 0 in UpdateContact worker
- Add parameter validation in Worker\UpdateContact::add - Address https://github.com/friendica/friendica/issues/12487#issuecomment-1366833644
This commit is contained in:
parent
5af956b92f
commit
e563de4de7
5 changed files with 71 additions and 17 deletions
|
@ -63,15 +63,21 @@ class UpdateContacts
|
|||
if (Contact::isLocal($contact['url'])) {
|
||||
continue;
|
||||
}
|
||||
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 (Worker::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], 'UpdateContact', $contact['id'])) {
|
||||
Logger::debug('Update by worker', ['id' => $contact['id'], 'count' => $count]);
|
||||
++$count;
|
||||
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue