From 6d0f0fc01b15f1a8812582cca13ac9bf75024672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 4 Jan 2024 11:12:03 +0100 Subject: [PATCH] Fix upgrade of user_ldap when oc_group_members contains duplicated uids MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- .../Version1190Date20230706134108.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/apps/user_ldap/lib/Migration/Version1190Date20230706134108.php b/apps/user_ldap/lib/Migration/Version1190Date20230706134108.php index 3f554f56e6436..71fdb536b1af3 100644 --- a/apps/user_ldap/lib/Migration/Version1190Date20230706134108.php +++ b/apps/user_ldap/lib/Migration/Version1190Date20230706134108.php @@ -99,13 +99,21 @@ protected function copyGroupMembershipData(): void { $result = $query->executeQuery(); while ($row = $result->fetch()) { $knownUsers = unserialize($row['owncloudusers']); + $knownUsers = array_unique($knownUsers); foreach ($knownUsers as $knownUser) { - $insert - ->setParameter('groupid', $row['owncloudname']) - ->setParameter('userid', $knownUser) - ; + try { + $insert + ->setParameter('groupid', $row['owncloudname']) + ->setParameter('userid', $knownUser) + ; - $insert->executeStatement(); + $insert->executeStatement(); + } catch (\OCP\DB\Exception $e) { + /* + * If it fails on unique constaint violation it may just be left over value from previous half-migration + * If it fails on something else, ignore as well, data will be filled by background job later anyway + */ + } } } $result->closeCursor();