Skip to content

Commit

Permalink
Merge pull request #42583 from nextcloud/backport/42576/stable28
Browse files Browse the repository at this point in the history
[stable28] Fix upgrade of user_ldap when oc_group_members contains duplicated uids
  • Loading branch information
come-nc authored Jan 4, 2024
2 parents c61fabe + 63def6d commit 80b5aed
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 80b5aed

Please sign in to comment.