From 94c90514608370256aaf8e3b7eb106a1642a50fa Mon Sep 17 00:00:00 2001 From: ralf Date: Thu, 23 Feb 2023 11:47:15 +0100 Subject: [PATCH] * 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 --- api/src/Accounts/Import.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/api/src/Accounts/Import.php b/api/src/Accounts/Import.php index 7504b51589..e8efad9070 100644 --- a/api/src/Accounts/Import.php +++ b/api/src/Accounts/Import.php @@ -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++; }