Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
45 changes: 45 additions & 0 deletions lib/Db/ShareWrapperRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,51 @@ public function deleteFromCircle(string $circleId): void {
$qb = $this->getShareDeleteSql();
$qb->andWhere($qb->exprLimit('share_with', $circleId));

$ids = array_map(
function (ShareWrapper $share): string {
return $share->getId();
},
$this->getItemsFromRequest($qb)
);

$this->deleteSharesAndChild($ids);
}


public function removeOrphanShares(): void {
$qb = $this->getShareSelectSql();
$expr = $qb->expr();
$qb->leftJoin(
CoreQueryBuilder::SHARE, CoreRequestBuilder::TABLE_SHARE, 'p',
$expr->andX($expr->eq('p.id', CoreQueryBuilder::SHARE . '.parent'))
);

$qb->filterNull('parent');
$qb->limitNull('id', false, 'p');

$ids = [];
$cursor = $qb->execute();
while ($data = $cursor->fetch()) {
$ids[] = $data['id'];
}
$cursor->closeCursor();

$this->deleteSharesAndChild($ids);
}


/**
* @param array $ids
*/
private function deleteSharesAndChild(array $ids): void {
$qb = $this->getShareDeleteSql();
$qb->andWhere(
$qb->expr()->orX(
$qb->exprLimitInArray('id', $ids),
$qb->exprLimitInArray('parent', $ids)
)
);

$qb->execute();
}
}
8 changes: 8 additions & 0 deletions lib/Service/MaintenanceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,14 @@ private function removeMembersWithNoCircles(): void {
}


private function removeOrphanShares(): void {
$this->shareWrapperRequest->removeOrphanShares();
}


/**
* @throws RequestBuilderException
*/
private function removeDeprecatedShares(): void {
$probe = new CircleProbe();
$probe->includePersonalCircles()
Expand Down
9 changes: 9 additions & 0 deletions lib/Service/ShareWrapperService.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ public function deleteSharesToCircle(string $circleId) {
}


/**
* @param string $circleId
*/
public function deleteAllSharesToCircle(string $circleId): void {
$this->cache->clear('');
$this->shareWrapperRequest->deleteSharesToCircle($circleId, '');
}


/**
* @param string $circleId
* @param FederatedUser|null $shareRecipient
Expand Down