Make NodaImportLogger more resilient, prevent error in case of duplicate import names

This commit is contained in:
Joshua Ramon Enslin 2024-12-12 12:43:11 +01:00
parent bf22f5541d
commit 546c17031a
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -32,8 +32,12 @@ final class NodaImportLogger {
$logStmt = $mysqli_noda->do_prepare("INSERT INTO `persinst_logged_imports` $logStmt = $mysqli_noda->do_prepare("INSERT INTO `persinst_logged_imports`
(`instance`, `institution_id`, `input_string`, `persinst_id`) (`instance`, `institution_id`, `input_string`, `persinst_id`)
VALUES (?, ?, ?, ?)"); VALUES (?, ?, ?, ?)");
try {
$logStmt->bind_param("sisi", $instance, $institution_id, $loggedName, $persinst_id); $logStmt->bind_param("sisi", $instance, $institution_id, $loggedName, $persinst_id);
$logStmt->execute(); $logStmt->execute();
}
catch (MDMysqliDuplicateKeysError $e) {
}
$logStmt->close(); $logStmt->close();
} }
@ -54,8 +58,12 @@ final class NodaImportLogger {
$logStmt = $mysqli_noda->do_prepare("INSERT INTO `orte_logged_imports` $logStmt = $mysqli_noda->do_prepare("INSERT INTO `orte_logged_imports`
(`instance`, `institution_id`, `input_string`, `ort_id`) (`instance`, `institution_id`, `input_string`, `ort_id`)
VALUES (?, ?, ?, ?)"); VALUES (?, ?, ?, ?)");
try {
$logStmt->bind_param("sisi", $instance, $institution_id, $name, $ort_id); $logStmt->bind_param("sisi", $instance, $institution_id, $name, $ort_id);
$logStmt->execute(); $logStmt->execute();
}
catch (MDMysqliDuplicateKeysError $e) {
}
$logStmt->close(); $logStmt->close();
} }
@ -76,8 +84,12 @@ final class NodaImportLogger {
$logStmt = $mysqli_noda->do_prepare("INSERT INTO `zeiten_logged_imports` $logStmt = $mysqli_noda->do_prepare("INSERT INTO `zeiten_logged_imports`
(`instance`, `institution_id`, `input_string`, `zeit_id`) (`instance`, `institution_id`, `input_string`, `zeit_id`)
VALUES (?, ?, ?, ?)"); VALUES (?, ?, ?, ?)");
try {
$logStmt->bind_param("sisi", $instance, $institution_id, $name, $zeit_id); $logStmt->bind_param("sisi", $instance, $institution_id, $name, $zeit_id);
$logStmt->execute(); $logStmt->execute();
}
catch (MDMysqliDuplicateKeysError $e) {
}
$logStmt->close(); $logStmt->close();
} }
@ -98,8 +110,12 @@ final class NodaImportLogger {
$logStmt = $mysqli_noda->do_prepare("INSERT INTO `tag_logged_imports` $logStmt = $mysqli_noda->do_prepare("INSERT INTO `tag_logged_imports`
(`instance`, `institution_id`, `input_string`, `tag_id`) (`instance`, `institution_id`, `input_string`, `tag_id`)
VALUES (?, ?, ?, ?)"); VALUES (?, ?, ?, ?)");
try {
$logStmt->bind_param("sisi", $instance, $institution_id, $name, $tag_id); $logStmt->bind_param("sisi", $instance, $institution_id, $name, $tag_id);
$logStmt->execute(); $logStmt->execute();
}
catch (MDMysqliDuplicateKeysError $e) {
}
$logStmt->close(); $logStmt->close();
} }