mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-07 03:29:19 +02:00
fix(import): skip rows with duplicate identifier instead of crashing
This commit is contained in:
1
TODO.md
1
TODO.md
@@ -1,5 +1,6 @@
|
||||
# TODO
|
||||
|
||||
## Fixes
|
||||
- [x] Fix CSV import UNIQUE constraint crash: skip rows whose identifier already exists in DB
|
||||
- [x] Fix wrong `require_once` depth in `public/admin/actions/page.php` (`../../` → `../../../`)
|
||||
- [x] Fix same path depth bug in `formulaire.php` and `publish.php`
|
||||
|
||||
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user