From ebbc17219f1669bc9eb8a83f15692fbf21eee165 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 27 Jul 2026 23:05:10 +0200 Subject: [PATCH 1/3] test: sort recipients in test Signed-off-by: Robin Appelman --- tests/lib/Sharing/AbstractSharingManagerTests.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/lib/Sharing/AbstractSharingManagerTests.php b/tests/lib/Sharing/AbstractSharingManagerTests.php index 96238de0aecca..2005bcbb53788 100644 --- a/tests/lib/Sharing/AbstractSharingManagerTests.php +++ b/tests/lib/Sharing/AbstractSharingManagerTests.php @@ -3097,6 +3097,7 @@ public function testGetShareWithSecret(): void { $this->assertGreaterThanOrEqual($before, $share['last_updated']); $this->assertLessThanOrEqual($after, $share['last_updated']); + usort($share['recipients'], fn (array $a, array $b): int => $a['value'] <=> $b['value']); $this->assertArrayHasKey('recipients', $share); $this->assertIsArray($share['recipients']); $this->assertCount(4, $share['recipients']); From 4cb718e3ad560800341325a8ba7eded236e70de8 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 27 Jul 2026 23:06:30 +0200 Subject: [PATCH 2/3] chore: fix rector style complaint Signed-off-by: Robin Appelman --- core/Sharing/Property/ExpirationDateSharePropertyType.php | 1 + 1 file changed, 1 insertion(+) diff --git a/core/Sharing/Property/ExpirationDateSharePropertyType.php b/core/Sharing/Property/ExpirationDateSharePropertyType.php index 7def2d4b7eae5..67f83bbaa67dd 100644 --- a/core/Sharing/Property/ExpirationDateSharePropertyType.php +++ b/core/Sharing/Property/ExpirationDateSharePropertyType.php @@ -62,6 +62,7 @@ public function isRequired(Share $share): bool { if ($this->hasRemoteRecipient($share) && $this->legacyManager->shareApiRemoteDefaultExpireDateEnforced()) { return true; } + return $this->hasLocalNonTokenAndEmailRecipient($share) && $this->legacyManager->shareApiInternalDefaultExpireDateEnforced(); } From 3df026ed09937eb8399ccb253e2af8bfc9612cac Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 27 Jul 2026 23:22:34 +0200 Subject: [PATCH 3/3] chore: psalm fixes Signed-off-by: Robin Appelman --- apps/sharing/tests/Command/CommandTest.php | 8 ++++++-- apps/sharing/tests/Controller/ApiV1ControllerTest.php | 11 +++++++++++ tests/lib/Sharing/AbstractSharingManagerTests.php | 9 +++++++++ tests/lib/Sharing/SharingManagerTest.php | 3 --- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/apps/sharing/tests/Command/CommandTest.php b/apps/sharing/tests/Command/CommandTest.php index b10dfef40c31e..934dfdcf7a6cc 100644 --- a/apps/sharing/tests/Command/CommandTest.php +++ b/apps/sharing/tests/Command/CommandTest.php @@ -33,6 +33,7 @@ use OCP\Sharing\Permission\SharePermission; use OCP\Sharing\Property\ShareProperty; use OCP\Sharing\Recipient\ShareRecipient; +use OCP\Sharing\Share; use OCP\Sharing\ShareAccessContext; use OCP\Sharing\ShareState; use OCP\Sharing\Source\ShareSource; @@ -42,6 +43,9 @@ use Symfony\Component\Console\Output\Output; use Test\Sharing\AbstractSharingManagerTests; +/** + * @psalm-import-type SharingShare from Share + */ #[Group(name: 'DB')] final class CommandTest extends AbstractSharingManagerTests { /** @var list> */ @@ -363,7 +367,7 @@ protected function deleteShare(ShareAccessContext $accessContext, string $id): v } /** - * @return array + * @return SharingShare */ #[Override] protected function getShare(ShareAccessContext $accessContext, string $id): array { @@ -380,7 +384,7 @@ protected function getShare(ShareAccessContext $accessContext, string $id): arra } /** - * @return array + * @return SharingShare[] */ #[Override] protected function getShares(ShareAccessContext $accessContext, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array { diff --git a/apps/sharing/tests/Controller/ApiV1ControllerTest.php b/apps/sharing/tests/Controller/ApiV1ControllerTest.php index bfee7b020155f..2424aba18d1cf 100644 --- a/apps/sharing/tests/Controller/ApiV1ControllerTest.php +++ b/apps/sharing/tests/Controller/ApiV1ControllerTest.php @@ -22,6 +22,7 @@ use OCP\Sharing\Permission\SharePermission; use OCP\Sharing\Property\ShareProperty; use OCP\Sharing\Recipient\ShareRecipient; +use OCP\Sharing\Share; use OCP\Sharing\ShareAccessContext; use OCP\Sharing\ShareState; use OCP\Sharing\Source\ShareSource; @@ -29,6 +30,10 @@ use Test\Sharing\AbstractSharingManagerTests; // TODO: Use Dispatcher + +/** + * @psalm-import-type SharingShare from Share + */ #[Group(name: 'DB')] final class ApiV1ControllerTest extends AbstractSharingManagerTests { public function testDefaultShareAccessContext(): void { @@ -146,11 +151,17 @@ protected function deleteShare(ShareAccessContext $accessContext, string $id): v $this->executeRequest($accessContext, fn (ApiV1Controller $controller): DataResponse => $controller->deleteShare($id)); } + /** + * @psalm-suppress MixedReturnTypeCoercion + */ #[Override] protected function getShare(ShareAccessContext $accessContext, string $id): array { return $this->executeRequest(new ShareAccessContext($accessContext->currentUser, null, [], $accessContext->overrideChecks), fn (ApiV1Controller $controller): DataResponse => $controller->getShare($id, $accessContext->secret, $accessContext->arguments)); } + /** + * @psalm-suppress MixedReturnTypeCoercion + */ #[Override] protected function getShares(ShareAccessContext $accessContext, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array { return $this->executeRequest($accessContext, function (ApiV1Controller $controller) use ($filterSourceTypeClass, $filterSourceTypeValue, $lastShareID, $limit): DataResponse { diff --git a/tests/lib/Sharing/AbstractSharingManagerTests.php b/tests/lib/Sharing/AbstractSharingManagerTests.php index 2005bcbb53788..b3420efc829f7 100644 --- a/tests/lib/Sharing/AbstractSharingManagerTests.php +++ b/tests/lib/Sharing/AbstractSharingManagerTests.php @@ -35,6 +35,9 @@ /** * @psalm-import-type SharingShare from Share * @psalm-import-type SharingRecipient from Share + * + * @psalm-suppress RedundantConditionGivenDocblockType + * @psalm-suppress PossiblyUndefinedArrayOffset */ abstract class AbstractSharingManagerTests extends TestCase { abstract protected function searchRecipients(ShareAccessContext $accessContext, ?array $filterRecipientTypeClasses, string $query, int $limit, int $offset, ?string $id = null): array; @@ -61,8 +64,14 @@ abstract protected function selectSharePermissionPreset(ShareAccessContext $acce abstract protected function deleteShare(ShareAccessContext $accessContext, string $id): void; + /** + * @return SharingShare + */ abstract protected function getShare(ShareAccessContext $accessContext, string $id): array; + /** + * @return SharingShare[] + */ abstract protected function getShares(ShareAccessContext $accessContext, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array; protected IDBConnection $dbConnection; diff --git a/tests/lib/Sharing/SharingManagerTest.php b/tests/lib/Sharing/SharingManagerTest.php index 117cb18c54d7b..519b60e1b6cc4 100644 --- a/tests/lib/Sharing/SharingManagerTest.php +++ b/tests/lib/Sharing/SharingManagerTest.php @@ -207,9 +207,6 @@ protected function getShare(ShareAccessContext $accessContext, string $id): arra } } - /** - * @return mixed[][] - */ #[\Override] protected function getShares(ShareAccessContext $accessContext, ?string $filterSourceTypeClass, ?string $filterSourceTypeValue, ?string $lastShareID, ?int $limit): array { try {