1
0
mirror of https://github.com/danog/telerpc.git synced 2024-11-26 20:14:48 +01:00
This commit is contained in:
Daniil Gentili 2024-06-16 16:54:15 +02:00
parent 2052afe6b3
commit 10e6417bc1

View File

@ -263,11 +263,14 @@ final class Main
}
}
$allowed = [];
$q = $this->pdo->prepare('SELECT error, method FROM errors');
$q->execute();
$r = $q->fetchAll(PDO::FETCH_COLUMN | PDO::FETCH_GROUP);
foreach (\array_merge($r, self::GLOBAL_CODES) as $error => $methods) {
if (\is_int($methods)) {
$allowed[$error] = true;
$methods = [];
}
$anyok = false;
@ -283,6 +286,7 @@ final class Main
if (!$anyok && $methods) {
continue;
}
$allowed[$error] = true;
$q = $this->pdo->prepare('SELECT description FROM error_descriptions WHERE error=?');
$q->execute([$error]);
@ -303,6 +307,19 @@ final class Main
}
}
$q = $this->pdo->prepare('SELECT error FROM error_descriptions');
$q->execute();
$r = $q->fetchAll(PDO::FETCH_COLUMN);
foreach ($r as $error) {
if (!isset($allowed[$error])) {
$q = $this->pdo->prepare('DELETE FROM errors WHERE error=?');
$q->execute([$error]);
$q = $this->pdo->prepare('DELETE FROM error_descriptions WHERE error=?');
$q->execute([$error]);
echo 'Delete '.$error."\n";
}
}
$r = $this->v2();
\file_put_contents('data/v2.json', \json_encode(['ok' => true, 'result' => $r]));
[$r, $hr] = $this->v3();