Actualiser api/index.php
CI / PHP Syntax Check (push) Has been cancelled
CI / JavaScript Lint (push) Has been cancelled
CI / Docker Build Test (push) Has been cancelled
CI / Validate Translation Files (push) Has been cancelled
Security Scan (Trivy) / Trivy — Docker image scan (push) Has been cancelled
Security Scan (Trivy) / Trivy — Filesystem scan (push) Has been cancelled
CI / Auto-merge develop → main (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled

This commit is contained in:
2026-06-27 17:43:03 +00:00
parent ef73630cad
commit 616818998d
+14 -3
View File
@@ -8990,7 +8990,7 @@ function importMergeBackup(PDO $db): void {
$db->beginTransaction();
try {
// --- 1. Tables référentielles simples : skip si key existe ---
// --- 1. Tables référentielles simples : upsert (update label/icon si key existe déjà) ---
$refTables = [
'categories' => ['key'],
'locations' => ['key'],
@@ -9004,9 +9004,20 @@ function importMergeBackup(PDO $db): void {
$where = [];
$params = [];
foreach ($uniqueCols as $c) { $where[] = "$c = ?"; $params[] = $row[$c]; }
$exists = $db->prepare("SELECT 1 FROM {$table} WHERE " . implode(' AND ', $where));
$exists = $db->prepare("SELECT id FROM {$table} WHERE " . implode(' AND ', $where));
$exists->execute($params);
if ($exists->fetch()) continue;
$existingId = $exists->fetchColumn();
if ($existingId) {
// Update label/icon (and keywords if present) from prod, keep local id/is_builtin
$updCols = array_diff(array_keys($row), $uniqueCols, ['is_builtin', 'sort_order']);
if (!empty($updCols)) {
$setClause = implode(', ', array_map(fn($c) => "$c = ?", $updCols));
$updParams = array_map(fn($c) => $row[$c], $updCols);
$updParams[] = $existingId;
$db->prepare("UPDATE {$table} SET {$setClause} WHERE id = ?")->execute($updParams);
}
continue;
}
$cols = array_keys($row);
$stmt = $db->prepare("INSERT INTO {$table} (" . implode(',', $cols) . ") VALUES (" . implode(',', array_fill(0, count($cols), '?')) . ")");
$stmt->execute(array_values($row));