import x
This commit is contained in:
@@ -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">
|
||||
|
||||
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user