Skip to content

Commit

Permalink
Merge pull request #42576 from nextcloud/fix/fix-ldap-upgrade-on-dupl…
Browse files Browse the repository at this point in the history
…icate-membership

Fix upgrade of user_ldap when oc_group_members contains duplicated uids
  • Loading branch information
come-nc committed Jan 4, 2024
2 parents 11124c7 + 6d0f0fc commit 2ab852e
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions apps/user_ldap/lib/Migration/Version1190Date20230706134108.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 2ab852e

Please sign in to comment.