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:
parent
cfff03f6e2
commit
d1933a1f74
|
@ -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]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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']);
|
||||
|
|
Loading…
Reference in a new issue