fix(import): skip rows with duplicate identifier instead of crashing

This commit is contained in:
Pontoporeia
2026-03-31 16:17:22 +02:00
parent e5d0598208
commit af06e09caa
2 changed files with 13 additions and 0 deletions

View File

@@ -168,6 +168,18 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['csv_file'])) {
$finalityId = $rowFin ? $rowFin['id'] : null;
}
// Skip if identifier already exists
if (!empty($identifier)) {
$stmtCheck = $pdo->prepare("SELECT id FROM theses WHERE identifier = ?");
$stmtCheck->execute([$identifier]);
if ($stmtCheck->fetch()) {
$db->rollback();
$skippedCount++;
$importResults[] = "⚠ Ligne $lineNumber: identifiant \"$identifier\" déjà présent, ignoré.";
continue;
}
}
// Insert thesis
$stmt = $pdo->prepare("
INSERT INTO theses (