Disable server records before probe to avoid zombies

- Also disable exact match records to avoid http/https double record issues
- Address friendica/friendica-directory#105
This commit is contained in:
Hypolite Petovan 2024-04-29 23:51:52 -04:00
parent cfff03f6e2
commit d1933a1f74
2 changed files with 20 additions and 6 deletions

View file

@ -57,4 +57,13 @@ class Server extends \Friendica\Directory\Model
return null;
}
public function getByBaseUrl(string $polled_url): ?array
{
$polled_url = trim($polled_url, '/');
return $this->atlas->fetchOne('SELECT s.* FROM `server` s WHERE s.`base_url` = :base_url',
['base_url' => $polled_url]
);
}
}

View file

@ -78,7 +78,16 @@ class Server
return 0;
}
// Disabling exact match first
if ($server = $this->serverModel->getByBaseUrl($polled_url)) {
$this->atlas->perform('UPDATE `server` SET `available` = 0 WHERE `id` = :server_id', ['server_id' => $server['id']]);
}
// Disabling before probe to avoid zombie records
$server = $this->serverModel->getByUrlAlias($polled_url);
if ($server) {
$this->atlas->perform('UPDATE `server` SET `available` = 0 WHERE `id` = :server_id', ['server_id' => $server['id']]);
}
if (
$server
@ -89,10 +98,6 @@ class Server
return $server['id'];
}
if ($server) {
$this->atlas->perform('UPDATE `server` SET `available` = 0 WHERE `id` = :server_id', ['server_id' => $server['id']]);
}
$probe_result = $this->getProbeResult($polled_url);
$parse_success = !empty($probe_result['data']['url']);