1
0
mirror of https://github.com/danog/telerpc.git synced 2024-11-30 04:38:57 +01:00

Autofix descriptions

This commit is contained in:
Daniil Gentili 2024-07-30 18:40:31 +02:00
parent a5cc439bc2
commit a236aa3404

View File

@ -307,14 +307,20 @@ final class Main implements RequestHandler
}
}
$q = $this->pool->prepare('SELECT error FROM error_descriptions');
foreach ($q->execute() as ['error' => $error]) {
$q = $this->pool->prepare('SELECT error, description FROM error_descriptions');
foreach ($q->execute() as ['error' => $error, 'description' => $description]) {
if (!isset($allowed[$error])) {
$q = $this->pool->prepare('DELETE FROM errors WHERE error=?');
$q->execute([$error]);
$q = $this->pool->prepare('DELETE FROM error_descriptions WHERE error=?');
$q->execute([$error]);
echo 'Delete '.$error."\n";
continue;
}
$newDesc = str_replace('](/', '](https://core.telegram.org/', $description);
if ($newDesc !== $description) {
$q = $this->pool->prepare('UPDATE error_descriptions SET description=? WHERE description=?');
$q->execute([$newDesc, $description]);
}
}