aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2025-01-24 11:55:36 +0100
committerGitHub <noreply@github.com>2025-01-24 11:55:36 +0100
commitf15fd324bec083ea3445ca913d31ffd083e318f5 (patch)
treeae207ef22384f476d4091c4dc3941161d406aade
parentf553197d119bc2316d939f30346d0d3047f5a69d (diff)
parent9fafcb267c4b90720ab9022b8c3f482dccf8c443 (diff)
downloadnextcloud-server-f15fd324bec083ea3445ca913d31ffd083e318f5.tar.gz
nextcloud-server-f15fd324bec083ea3445ca913d31ffd083e318f5.zip
Merge pull request #50393 from nextcloud/backport/50389/stable31
[stable31] Revert "fix(Share20\Manager): Ensure node is still accessible when checking share"
-rw-r--r--lib/private/Share20/Manager.php9
-rw-r--r--tests/lib/Share20/ManagerTest.php33
2 files changed, 4 insertions, 38 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 5911882e808..35166c37ee3 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -1464,15 +1464,6 @@ class Manager implements IManager {
$this->deleteShare($share);
throw new ShareNotFound($this->l->t('The requested share does not exist anymore'));
}
-
- try {
- $share->getNode();
- // Ignore share, file is still accessible
- } catch (NotFoundException) {
- // Access lost, but maybe only temporarily, so don't delete the share right away
- throw new ShareNotFound($this->l->t('The requested share does not exist anymore'));
- }
-
if ($this->config->getAppValue('files_sharing', 'hide_disabled_user_shares', 'no') === 'yes') {
$uids = array_unique([$share->getShareOwner(),$share->getSharedBy()]);
foreach ($uids as $uid) {
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index 1afe0473cea..6df97423989 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -25,7 +25,6 @@ use OCP\Files\Mount\IMountManager;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Mount\IShareOwnerlessMount;
use OCP\Files\Node;
-use OCP\Files\NotFoundException;
use OCP\Files\Storage\IStorage;
use OCP\HintException;
use OCP\IAppConfig;
@@ -675,24 +674,6 @@ class ManagerTest extends \Test\TestCase {
}
- public function testGetShareByIdNodeAccessible(): void {
- $share = $this->createMock(IShare::class);
- $share
- ->expects($this->once())
- ->method('getNode')
- ->willThrowException(new NotFoundException());
-
- $this->defaultProvider
- ->expects($this->once())
- ->method('getShareById')
- ->with(42)
- ->willReturn($share);
-
- $this->expectException(ShareNotFound::class);
- $this->manager->getShareById('default:42');
- }
-
-
public function testGetExpiredShareById(): void {
$this->expectException(\OCP\Share\Exceptions\ShareNotFound::class);
@@ -2901,10 +2882,9 @@ class ManagerTest extends \Test\TestCase {
}
public function testGetSharesBy(): void {
- $node = $this->createMock(Folder::class);
-
$share = $this->manager->newShare();
- $share->setNode($node);
+
+ $node = $this->createMock(Folder::class);
$this->defaultProvider->expects($this->once())
->method('getSharesBy')
@@ -2957,8 +2937,6 @@ class ManagerTest extends \Test\TestCase {
* deleted (as they are evaluated). but share 8 should still be there.
*/
public function testGetSharesByExpiredLinkShares(): void {
- $node = $this->createMock(File::class);
-
$manager = $this->createManagerMock()
->setMethods(['deleteShare'])
->getMock();
@@ -2972,7 +2950,6 @@ class ManagerTest extends \Test\TestCase {
for ($i = 0; $i < 8; $i++) {
$share = $this->manager->newShare();
$share->setId($i);
- $share->setNode($node);
$shares[] = $share;
}
@@ -2993,6 +2970,8 @@ class ManagerTest extends \Test\TestCase {
$shares2[] = clone $shares[$i];
}
+ $node = $this->createMock(File::class);
+
/*
* Simulate the getSharesBy call.
*/
@@ -3154,10 +3133,8 @@ class ManagerTest extends \Test\TestCase {
$date = new \DateTime();
$date->setTime(0, 0, 0);
$date->add(new \DateInterval('P2D'));
- $node = $this->createMock(File::class);
$share = $this->manager->newShare();
$share->setExpirationDate($date);
- $share->setNode($node);
$share->setShareOwner('owner');
$share->setSharedBy('sharedBy');
@@ -3235,10 +3212,8 @@ class ManagerTest extends \Test\TestCase {
$date = new \DateTime();
$date->setTime(0, 0, 0);
$date->add(new \DateInterval('P2D'));
- $node = $this->createMock(Folder::class);
$share = $this->manager->newShare();
$share->setExpirationDate($date);
- $share->setNode($node);
$this->defaultProvider->expects($this->once())
->method('getShareByToken')