import x
All checks were successful
Deploy / deploy-production (push) Has been skipped
Deploy / deploy-staging (push) Successful in 5s

This commit is contained in:
2026-04-11 03:29:21 +02:00
parent 067f962cb2
commit 94f3295b6c
2 changed files with 29 additions and 2 deletions

View File

@@ -23,6 +23,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<div class="pill">Module</div>
<h1 style="margin-top:.75rem;">Module verwalten</h1>
<p class="muted">Hier siehst du nur aktive Module. Installierte Module kannst du unten verwalten.</p>
<p style="margin-top:.75rem;">
<a class="nav-link" href="/modules/sql-import">Zentralen SQL-Import oeffnen</a>
</p>
<?php if ($error): ?>
<div class="bg-red-900 border-l-4 border-red-500 text-red-100 p-4 mb-6" role="alert">

View File

@@ -74,7 +74,7 @@ final class SqlDataImporter
foreach ($pendingStatements as $statement) {
try {
$this->pdo->exec($statement);
$this->execStatementWithRecovery($statement);
$executed++;
$progressMade = true;
} catch (\Throwable $exception) {
@@ -93,7 +93,7 @@ final class SqlDataImporter
if (!$progressMade) {
try {
$this->pdo->exec($deferredStatements[0]);
$this->execStatementWithRecovery($deferredStatements[0]);
} catch (\Throwable $exception) {
throw new \RuntimeException($deferredStatements[0], 0, $exception);
}
@@ -105,6 +105,30 @@ final class SqlDataImporter
return $executed;
}
private function execStatementWithRecovery(string $statement): void
{
if ($this->driver !== 'pgsql' || !$this->pdo->inTransaction()) {
$this->pdo->exec($statement);
return;
}
$savepoint = 'sql_import_' . substr(sha1($statement . microtime(true)), 0, 12);
$this->pdo->exec('SAVEPOINT ' . $savepoint);
try {
$this->pdo->exec($statement);
$this->pdo->exec('RELEASE SAVEPOINT ' . $savepoint);
} catch (\Throwable $exception) {
try {
$this->pdo->exec('ROLLBACK TO SAVEPOINT ' . $savepoint);
$this->pdo->exec('RELEASE SAVEPOINT ' . $savepoint);
} catch (\Throwable) {
}
throw $exception;
}
}
private function shouldRetryDeferredImportStatement(\Throwable $exception, string $statement): bool
{
if ($this->driver !== 'pgsql') {