diff --git a/api/src/Db.php b/api/src/Db.php index 6cd89da820..729fbd38a5 100644 --- a/api/src/Db.php +++ b/api/src/Db.php @@ -819,7 +819,10 @@ class Db catch(\mysqli_sql_exception $e) { if (!($reconnect && $this->Type == 'mysql' && ($e->getCode() == 2006 || $e->getMessage() === 'MySQL server has gone away'))) { - if ($e->getCode() == 1064) // You have an error in your SQL syntax + if (in_array($e->getCode(), [ + 1064, // You have an error in your SQL syntax + 1062, // Duplicate entry + ])) { throw new Db\Exception\InvalidSql($e->getMessage(), $e->getCode(), $e); } diff --git a/api/src/Db/Backup.php b/api/src/Db/Backup.php index 65fd2c5ba6..c4b1a9983f 100644 --- a/api/src/Db/Backup.php +++ b/api/src/Db/Backup.php @@ -691,7 +691,7 @@ class Backup } /** - * Insert multiple rows ignoring doublicate entries + * Insert multiple rows ignoring duplicate entries * * @param string $table * @param array $rows @@ -704,14 +704,14 @@ class Backup } catch(Exception\InvalidSql $e) { - // try inserting them one by one, ignoring doublicates + // try inserting them one by one, ignoring duplicates foreach($rows as $data) { try { $this->db->insert($table, $data, False, __LINE__, __FILE__, false, false, $schema); } catch(Exception\InvalidSql $e) { - echo "

".$e->getMessage()."

\n"; + echo "

$table: ".$e->getMessage()." ignored

\n"; } } }