Skip to content

Commit edd8a03

Browse files
authored
Merge pull request #47326 from nextcloud/revert-47227-backport/47192/stable28
Revert "[stable28] Apply group limit on remove from group"
2 parents 617e856 + f2559e4 commit edd8a03

File tree

4 files changed

+8
-168
lines changed

4 files changed

+8
-168
lines changed

cypress/e2e/files_sharing/limit_to_same_group.cy.ts

Lines changed: 0 additions & 107 deletions
This file was deleted.

lib/private/Share20/DefaultShareProvider.php

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
use OCP\Mail\IMailer;
5454
use OCP\Share\Exceptions\ShareNotFound;
5555
use OCP\Share\IAttributes;
56-
use OCP\Share\IManager;
5756
use OCP\Share\IShare;
5857
use OCP\Share\IShareProvider;
5958
use function str_starts_with;
@@ -103,7 +102,6 @@ public function __construct(
103102
IFactory $l10nFactory,
104103
IURLGenerator $urlGenerator,
105104
ITimeFactory $timeFactory,
106-
private IManager $shareManager,
107105
) {
108106
$this->dbConn = $connection;
109107
$this->userManager = $userManager;
@@ -1306,7 +1304,6 @@ public function groupDeleted($gid) {
13061304
*
13071305
* @param string $uid
13081306
* @param string $gid
1309-
* @return void
13101307
*/
13111308
public function userDeletedFromGroup($uid, $gid) {
13121309
/*
@@ -1318,7 +1315,7 @@ public function userDeletedFromGroup($uid, $gid) {
13181315
->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP)))
13191316
->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($gid)));
13201317

1321-
$cursor = $qb->executeQuery();
1318+
$cursor = $qb->execute();
13221319
$ids = [];
13231320
while ($row = $cursor->fetch()) {
13241321
$ids[] = (int)$row['id'];
@@ -1335,45 +1332,7 @@ public function userDeletedFromGroup($uid, $gid) {
13351332
->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)))
13361333
->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($uid)))
13371334
->andWhere($qb->expr()->in('parent', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY)));
1338-
$qb->executeStatement();
1339-
}
1340-
}
1341-
1342-
if ($this->shareManager->shareWithGroupMembersOnly()) {
1343-
$user = $this->userManager->get($uid);
1344-
if ($user === null) {
1345-
return;
1346-
}
1347-
$userGroups = $this->groupManager->getUserGroupIds($user);
1348-
1349-
// Delete user shares received by the user from users in the group.
1350-
$userReceivedShares = $this->shareManager->getSharedWith($uid, IShare::TYPE_USER, null, -1);
1351-
foreach ($userReceivedShares as $share) {
1352-
$owner = $this->userManager->get($share->getSharedBy());
1353-
if ($owner === null) {
1354-
continue;
1355-
}
1356-
$ownerGroups = $this->groupManager->getUserGroupIds($owner);
1357-
$mutualGroups = array_intersect($userGroups, $ownerGroups);
1358-
1359-
if (count($mutualGroups) === 0) {
1360-
$this->shareManager->deleteShare($share);
1361-
}
1362-
}
1363-
1364-
// Delete user shares from the user to users in the group.
1365-
$userEmittedShares = $this->shareManager->getSharesBy($uid, IShare::TYPE_USER, null, true, -1);
1366-
foreach ($userEmittedShares as $share) {
1367-
$recipient = $this->userManager->get($share->getSharedWith());
1368-
if ($recipient === null) {
1369-
continue;
1370-
}
1371-
$recipientGroups = $this->groupManager->getUserGroupIds($recipient);
1372-
$mutualGroups = array_intersect($userGroups, $recipientGroups);
1373-
1374-
if (count($mutualGroups) === 0) {
1375-
$this->shareManager->deleteShare($share);
1376-
}
1335+
$qb->execute();
13771336
}
13781337
}
13791338
}

lib/private/Share20/ProviderFactory.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ protected function defaultShareProvider() {
106106
$this->serverContainer->getL10NFactory(),
107107
$this->serverContainer->getURLGenerator(),
108108
$this->serverContainer->query(ITimeFactory::class),
109-
$this->serverContainer->get(IManager::class),
110109
);
111110
}
112111

tests/lib/Share20/DefaultShareProviderTest.php

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
use OCP\IUserManager;
4040
use OCP\L10N\IFactory;
4141
use OCP\Mail\IMailer;
42-
use OCP\Share\IManager as IShareManager;
4342
use OCP\Share\IShare;
4443
use PHPUnit\Framework\MockObject\MockObject;
4544

@@ -83,9 +82,6 @@ class DefaultShareProviderTest extends \Test\TestCase {
8382
/** @var ITimeFactory|MockObject */
8483
protected $timeFactory;
8584

86-
/** @var IShareManager&MockObject */
87-
protected $shareManager;
88-
8985
protected function setUp(): void {
9086
$this->dbConn = \OC::$server->getDatabaseConnection();
9187
$this->userManager = $this->createMock(IUserManager::class);
@@ -97,7 +93,6 @@ protected function setUp(): void {
9793
$this->defaults = $this->getMockBuilder(Defaults::class)->disableOriginalConstructor()->getMock();
9894
$this->urlGenerator = $this->createMock(IURLGenerator::class);
9995
$this->timeFactory = $this->createMock(ITimeFactory::class);
100-
$this->shareManager = $this->createMock(IShareManager::class);
10196

10297
$this->userManager->expects($this->any())->method('userExists')->willReturn(true);
10398
$this->timeFactory->expects($this->any())->method('now')->willReturn(new \DateTimeImmutable("2023-05-04 00:00 Europe/Berlin"));
@@ -114,8 +109,7 @@ protected function setUp(): void {
114109
$this->defaults,
115110
$this->l10nFactory,
116111
$this->urlGenerator,
117-
$this->timeFactory,
118-
$this->shareManager,
112+
$this->timeFactory
119113
);
120114
}
121115

@@ -476,8 +470,7 @@ public function testDeleteSingleShare() {
476470
$this->defaults,
477471
$this->l10nFactory,
478472
$this->urlGenerator,
479-
$this->timeFactory,
480-
$this->shareManager,
473+
$this->timeFactory
481474
])
482475
->setMethods(['getShareById'])
483476
->getMock();
@@ -572,8 +565,7 @@ public function testDeleteGroupShareWithUserGroupShares() {
572565
$this->defaults,
573566
$this->l10nFactory,
574567
$this->urlGenerator,
575-
$this->timeFactory,
576-
$this->shareManager,
568+
$this->timeFactory
577569
])
578570
->setMethods(['getShareById'])
579571
->getMock();
@@ -2533,8 +2525,7 @@ public function testGetSharesInFolder() {
25332525
$this->defaults,
25342526
$this->l10nFactory,
25352527
$this->urlGenerator,
2536-
$this->timeFactory,
2537-
$this->shareManager,
2528+
$this->timeFactory
25382529
);
25392530

25402531
$password = md5(time());
@@ -2632,8 +2623,7 @@ public function testGetAccessListNoCurrentAccessRequired() {
26322623
$this->defaults,
26332624
$this->l10nFactory,
26342625
$this->urlGenerator,
2635-
$this->timeFactory,
2636-
$this->shareManager,
2626+
$this->timeFactory
26372627
);
26382628

26392629
$u1 = $userManager->createUser('testShare1', 'test');
@@ -2729,8 +2719,7 @@ public function testGetAccessListCurrentAccessRequired() {
27292719
$this->defaults,
27302720
$this->l10nFactory,
27312721
$this->urlGenerator,
2732-
$this->timeFactory,
2733-
$this->shareManager,
2722+
$this->timeFactory
27342723
);
27352724

27362725
$u1 = $userManager->createUser('testShare1', 'test');

0 commit comments

Comments
 (0)