* AD/LDAP: fix SQL error "duplicate entry 'X' on egw_accounts.account_lid" when updating an existing account

also fixed TypeError deleting no longer existing groups
This commit is contained in:
ralf 2023-02-23 11:47:15 +01:00
parent 235a69e75e
commit 94c9051460

View File

@ -271,7 +271,7 @@ class Import
return $attr !== null && $attr !== '';
});
unset($relevant['person_id']); // is always different as it's the UID, no need to consider
$to_update = $relevant + $sql_account;
$to_update = ['account_id' => $account_id] + $relevant + $sql_account;
// fix accounts without firstname
if (!isset($to_update['account_firstname']) && $to_update['account_lastname'] === $to_update['account_fullname'])
{
@ -307,7 +307,7 @@ class Import
}
catch (\Exception $e) {
$this->logger("Error updating user '$account[account_lid]' (#$account_id): ".$e->getMessage().' ('.$e->getCode().')', 'error');
$this->logger('$to_update='.json_encode($to_update, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), 'error');
$this->logger('$to_update='.json_encode($to_update, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), 'detail');
$errors++;
continue;
}
@ -464,7 +464,7 @@ class Import
{
foreach($sql_users as $account_id => $account_lid)
{
if ($this->deleteAccount($account_id, $account_lid, $this->logger))
if ($this->deleteAccount($account_id, $account_lid))
{
$deleted++;
}
@ -657,7 +657,12 @@ class Import
{
if ($delete === 'yes')
{
if ($this->deleteAccount($account_id, $account_lid, $dry_run))
if ($dry_run)
{
$this->logger("Dry-run: would delete group '$group[account_lid]' (#$sql_id)", 'detail');
$delete++;
}
elseif ($this->deleteAccount($account_id, $account_lid))
{
$deleted++;
}