Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed Mar 28, 2025
commit 0193e9e6b15b58ef584a434c01e62ee66088e7db
31 changes: 21 additions & 10 deletions lib/Command/MigrateCustomGroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function migrateTeams(): void {
}

$name = $rowCG['display_name'];
while(strlen($name) < 3) {
while (strlen($name) < 3) {
$name = '_' . $name;
}

Expand Down Expand Up @@ -122,8 +122,14 @@ public function migrateTeams(): void {
continue; // owner is already in the circles
}

$this->output->writeln(' - new member <info>' . $userId .'</info>');
$member = $this->circlesManager->addMember($circle->getSingleId(), $this->cachedFed($userId));
$fedUser = $this->cachedFed($userId);
if ($fedUser === null) {
$this->output->writeln('<error>unknown user</error> ' . $userId);
continue;
}
$this->output->writeln(' - new member <info>' . $userId . '</info>');

$member = $this->circlesManager->addMember($circle->getSingleId(), $fedUser);
if ($rowM['role'] === '1') {
$this->circlesManager->levelMember($member->getId(), Member::LEVEL_ADMIN);
}
Expand Down Expand Up @@ -164,7 +170,7 @@ public function updateShares(string $groupUri, string $circleId, array $memberId
->where($update->expr()->in('id', $update->createNamedParameter($shareIds, IQueryBuilder::PARAM_INT_ARRAY)));

$count = $update->executeStatement();
$this->output->writeln('> ' . $count . ' shares updated');
$this->output->writeln('> ' . ((string)$count) . ' shares updated');

$this->fixShareChildren($shareIds, $memberIds);
}
Expand Down Expand Up @@ -197,19 +203,24 @@ private function cachedFed(string $userId): ?FederatedUser {
private function fixShareChildren(array $shareIds, array $memberIds): void {
$update = $this->connection->getQueryBuilder();
$update->update('share')
->set('share_type', $update->createNamedParameter(IShare::TYPE_CIRCLE))
->set('share_with', $update->createParameter('new_recipient'))
->where($update->expr()->in('parent', $update->createNamedParameter($shareIds, IQueryBuilder::PARAM_INT_ARRAY)))
->andWhere($update->expr()->eq('share_with', $update->createParameter('old_recipient')));
->set('share_type', $update->createNamedParameter(IShare::TYPE_CIRCLE))
->set('share_with', $update->createParameter('new_recipient'))
->where($update->expr()->in('parent', $update->createNamedParameter($shareIds, IQueryBuilder::PARAM_INT_ARRAY)))
->andWhere($update->expr()->eq('share_with', $update->createParameter('old_recipient')));

$count = 0;
foreach($memberIds as $memberId) {
foreach ($memberIds as $memberId) {
$fedUser = $this->cachedFed($memberId);
if ($fedUser === null) {
// we dont update, user does not exist anymore
continue;
}
$update->setParameter('old_recipient', $memberId);
$update->setParameter('new_recipient', $fedUser->getSingleId());
$count += $update->executeStatement();
}

$this->output->writeln('> ' . $count . ' children shares updated');
$this->output->writeln('> ' . ((string)$count) . ' children shares updated');
}


Expand Down
Loading