mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-21 23:43:17 +01:00
fix restoring 1.8 database gave "Duplicate entry" error by mapping that (again) to InvalidSql exception (was changed due to PHP 8)
This commit is contained in:
parent
3cfdca0ae9
commit
95ba35bfeb
@ -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);
|
||||
}
|
||||
|
@ -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 "<p>".$e->getMessage()."</p>\n";
|
||||
echo "<p>$table: ".$e->getMessage()." ignored</p>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user