Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable31] Revert "fix(Share20\Manager): Ensure node is still accessible when checking share" #50393

Merged
merged 1 commit into from
Jan 24, 2025
Merged
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
9 changes: 0 additions & 9 deletions lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1464,15 +1464,6 @@ protected function checkShare(IShare $share): void {
$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) {
Expand Down
33 changes: 4 additions & 29 deletions tests/lib/Share20/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
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;
Expand Down Expand Up @@ -675,24 +674,6 @@ public function testGetShareById(): void {
}


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);

Expand Down Expand Up @@ -2901,10 +2882,9 @@ public function testCreateShareOfIncomingFederatedShare(): void {
}

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')
Expand Down Expand Up @@ -2957,8 +2937,6 @@ public function testGetSharesByOwnerless(): void {
* 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();
Expand All @@ -2972,7 +2950,6 @@ public function testGetSharesByExpiredLinkShares(): void {
for ($i = 0; $i < 8; $i++) {
$share = $this->manager->newShare();
$share->setId($i);
$share->setNode($node);
$shares[] = $share;
}

Expand All @@ -2993,6 +2970,8 @@ public function testGetSharesByExpiredLinkShares(): void {
$shares2[] = clone $shares[$i];
}

$node = $this->createMock(File::class);

/*
* Simulate the getSharesBy call.
*/
Expand Down Expand Up @@ -3154,10 +3133,8 @@ public function testGetShareByTokenHideDisabledUser(): void {
$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');

Expand Down Expand Up @@ -3235,10 +3212,8 @@ public function testGetShareByTokenNotExpired(): void {
$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')
Expand Down
Loading