Skip to content

Commit

Permalink
fix: fix share cleanup for deleted groups with sharding
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Aug 21, 2024
1 parent 364156d commit 7932b86
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions lib/private/Share20/DefaultShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -1203,10 +1203,14 @@ public function groupDeleted($gid) {

if (!empty($ids)) {
$chunks = array_chunk($ids, 100);

$qb = $this->dbConn->getQueryBuilder();
$qb->delete('share')
->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)))
->andWhere($qb->expr()->in('parent', $qb->createParameter('parents')));

foreach ($chunks as $chunk) {
$qb->delete('share')
->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)))
->andWhere($qb->expr()->in('parent', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY)));
$qb->setParameter('parents', $chunk, IQueryBuilder::PARAM_INT_ARRAY);
$qb->execute();
}
}
Expand Down Expand Up @@ -1247,14 +1251,18 @@ public function userDeletedFromGroup($uid, $gid) {

if (!empty($ids)) {
$chunks = array_chunk($ids, 100);

/*
* Delete all special shares with this user for the found group shares
*/
$qb = $this->dbConn->getQueryBuilder();
$qb->delete('share')
->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)))
->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($uid)))
->andWhere($qb->expr()->in('parent', $qb->createParameter('parents')));

foreach ($chunks as $chunk) {
/*
* Delete all special shares with this users for the found group shares
*/
$qb->delete('share')
->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)))
->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($uid)))
->andWhere($qb->expr()->in('parent', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY)));
$qb->setParameter('parents', $chunk, IQueryBuilder::PARAM_INT_ARRAY);
$qb->executeStatement();
}
}
Expand Down

0 comments on commit 7932b86

Please sign in to comment.