From a236aa3404fd0ce353a6e4a795795586689d3629 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 30 Jul 2024 18:40:31 +0200 Subject: [PATCH] Autofix descriptions --- src/Main.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Main.php b/src/Main.php index 8061a6a..90ea396 100644 --- a/src/Main.php +++ b/src/Main.php @@ -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]); } }