diff --git a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php index 7229de5dadd..42df72fe442 100644 --- a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php +++ b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php @@ -44,7 +44,6 @@ use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; use OCP\Share\IProviderFactory; use OCP\Share\IShare; -use OCP\Snowflake\ISnowflakeGenerator; use OCP\Util; use Override; use Psr\Log\LoggerInterface; @@ -70,7 +69,6 @@ class CloudFederationProviderFiles implements ISignedCloudFederationProvider { private readonly IFilenameValidator $filenameValidator, private readonly IProviderFactory $shareProviderFactory, private readonly SetupManager $setupManager, - private readonly ISnowflakeGenerator $snowflakeGenerator, private readonly ExternalShareMapper $externalShareMapper, ) { } @@ -145,7 +143,7 @@ class CloudFederationProviderFiles implements ISignedCloudFederationProvider { } $externalShare = new ExternalShare(); - $externalShare->setId($this->snowflakeGenerator->nextId()); + $externalShare->setId(); $externalShare->setRemote($remote); $externalShare->setRemoteId($remoteId); $externalShare->setShareToken($token); @@ -177,9 +175,9 @@ class CloudFederationProviderFiles implements ISignedCloudFederationProvider { ->setType('remote_share') ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/'), $ownerDisplayName]) ->setAffectedUser($shareWith) - ->setObject('remote_share', $externalShare->getId(), $name); + ->setObject('remote_share', (string)$externalShare->getId(), $name); Server::get(IActivityManager::class)->publish($event); - $this->notifyAboutNewShare($shareWith, $externalShare->getId(), $ownerFederatedId, $sharedByFederatedId, $name, $ownerDisplayName); + $this->notifyAboutNewShare($shareWith, (string)$externalShare->getId(), $ownerFederatedId, $sharedByFederatedId, $name, $ownerDisplayName); // If auto-accept is enabled, accept the share if ($this->federatedShareProvider->isFederatedTrustedShareAutoAccept() && $trustedServers?->isTrustedServer($remote) === true) { @@ -193,9 +191,9 @@ class CloudFederationProviderFiles implements ISignedCloudFederationProvider { ->setType('remote_share') ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_RECEIVED, [$ownerFederatedId, trim($name, '/'), $ownerDisplayName]) ->setAffectedUser($user->getUID()) - ->setObject('remote_share', $externalShare->getId(), $name); + ->setObject('remote_share', (string)$externalShare->getId(), $name); Server::get(IActivityManager::class)->publish($event); - $this->notifyAboutNewShare($user->getUID(), $externalShare->getId(), $ownerFederatedId, $sharedByFederatedId, $name, $ownerDisplayName); + $this->notifyAboutNewShare($user->getUID(), (string)$externalShare->getId(), $ownerFederatedId, $sharedByFederatedId, $name, $ownerDisplayName); // If auto-accept is enabled, accept the share if ($this->federatedShareProvider->isFederatedTrustedShareAutoAccept() && $trustedServers?->isTrustedServer($remote) === true) { @@ -204,7 +202,7 @@ class CloudFederationProviderFiles implements ISignedCloudFederationProvider { } } - return $externalShare->getId(); + return (string)$externalShare->getId(); } catch (\Exception $e) { $this->logger->error('Server can not add remote share.', [ 'app' => 'files_sharing', @@ -466,7 +464,7 @@ class CloudFederationProviderFiles implements ISignedCloudFederationProvider { $notification = $this->notificationManager->createNotification(); $notification->setApp('files_sharing') ->setUser($share->getUser()) - ->setObject('remote_share', $share->getId()); + ->setObject('remote_share', (string)$share->getId()); $this->notificationManager->markProcessed($notification); $event = $this->activityManager->generateEvent(); diff --git a/apps/files_sharing/lib/External/ExternalShare.php b/apps/files_sharing/lib/External/ExternalShare.php index db2c08f9daf..f6537211169 100644 --- a/apps/files_sharing/lib/External/ExternalShare.php +++ b/apps/files_sharing/lib/External/ExternalShare.php @@ -12,15 +12,13 @@ namespace OCA\Files_Sharing\External; use OC\Files\Filesystem; use OCA\Files_Sharing\ResponseDefinitions; -use OCP\AppFramework\Db\Entity; +use OCP\AppFramework\Db\SnowflakeAwareEntity; use OCP\DB\Types; use OCP\IGroup; use OCP\IUser; use OCP\Share\IShare; /** - * @method string getId() - * @method void setId(string $id) * @method string getParent() * @method void setParent(string $parent) * @method int|null getShareType() @@ -46,7 +44,7 @@ use OCP\Share\IShare; * * @psalm-import-type Files_SharingRemoteShare from ResponseDefinitions */ -class ExternalShare extends Entity implements \JsonSerializable { +class ExternalShare extends SnowflakeAwareEntity implements \JsonSerializable { protected string $parent = '-1'; protected ?int $shareType = null; protected ?string $remote = null; @@ -96,7 +94,7 @@ class ExternalShare extends Entity implements \JsonSerializable { public function jsonSerialize(): array { $parent = $this->getParent(); return [ - 'id' => $this->getId(), + 'id' => (string)$this->getId(), 'parent' => $parent, 'share_type' => $this->getShareType() ?? IShare::TYPE_USER, // unfortunately nullable on the DB level, but never null. 'remote' => $this->getRemote(), @@ -107,13 +105,6 @@ class ExternalShare extends Entity implements \JsonSerializable { 'user' => $this->getUser(), 'mountpoint' => $this->getMountpoint(), 'accepted' => $this->getAccepted(), - - // Added later on - 'file_id' => null, - 'mimetype' => null, - 'permissions' => null, - 'mtime' => null, - 'type' => null, ]; } diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index 56aac592efc..9322348512b 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -34,7 +34,6 @@ use OCP\IUserSession; use OCP\Notification\IManager; use OCP\OCS\IDiscoveryService; use OCP\Share\IShare; -use OCP\Snowflake\ISnowflakeGenerator; use Psr\Log\LoggerInterface; class Manager { @@ -57,7 +56,6 @@ class Manager { private SetupManager $setupManager, private ICertificateManager $certificateManager, private ExternalShareMapper $externalShareMapper, - private ISnowflakeGenerator $snowflakeGenerator, ) { $this->user = $userSession->getUser(); } @@ -186,7 +184,7 @@ class Manager { $subShare = $this->externalShareMapper->getUserShare($externalShare, $user); } catch (DoesNotExistException) { $subShare = new ExternalShare(); - $subShare->setId($this->snowflakeGenerator->nextId()); + $subShare->setId(); $subShare->setRemote($externalShare->getRemote()); $subShare->setPassword($externalShare->getPassword()); $subShare->setName($externalShare->getName()); @@ -195,7 +193,7 @@ class Manager { $subShare->setMountpoint($mountPoint ?? $externalShare->getMountpoint()); $subShare->setAccepted($accepted); $subShare->setRemoteId($externalShare->getRemoteId()); - $subShare->setParent($externalShare->getId()); + $subShare->setParent((string)$externalShare->getId()); $subShare->setShareType($externalShare->getShareType()); $subShare->setShareToken($externalShare->getShareToken()); $this->externalShareMapper->insert($subShare); @@ -317,7 +315,7 @@ class Manager { $filter = $this->notificationManager->createNotification(); $filter->setApp('files_sharing') ->setUser($user->getUID()) - ->setObject('remote_share', $remoteShare->getId()); + ->setObject('remote_share', (string)$remoteShare->getId()); $this->notificationManager->markProcessed($filter); } diff --git a/apps/files_sharing/lib/ResponseDefinitions.php b/apps/files_sharing/lib/ResponseDefinitions.php index 58277577eab..72a7b4efca4 100644 --- a/apps/files_sharing/lib/ResponseDefinitions.php +++ b/apps/files_sharing/lib/ResponseDefinitions.php @@ -82,21 +82,21 @@ namespace OCA\Files_Sharing; * * @psalm-type Files_SharingRemoteShare = array{ * accepted: int, - * file_id: int|null, * id: string, - * mimetype: string|null, * mountpoint: string, - * mtime: int|null, * name: string, * owner: string, * parent: string|null, - * permissions: int|null, * remote: string, * remote_id: string, * share_token: string, * share_type: int, - * type: string|null, * user: string, + * file_id?: int, + * mimetype?: string, + * permissions?: int, + * mtime?: int, + * type?: string, * } * * @psalm-type Files_SharingSharee = array{ diff --git a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php index 58c27d07c17..088bfd1f467 100644 --- a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php +++ b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php @@ -14,7 +14,6 @@ use OCP\Federation\ICloudId; use OCP\Federation\ICloudIdManager; use OCP\IDBConnection; use OCP\Server; -use OCP\Snowflake\ISnowflakeGenerator; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\Console\Input\InputInterface; @@ -64,7 +63,7 @@ class CleanupRemoteStoragesTest extends TestCase { if (isset($storage['share_token'])) { $externalShare = new ExternalShare(); - $externalShare->setId(Server::get(ISnowflakeGenerator::class)->nextId()); + $externalShare->setId(); $externalShare->setShareToken($storage['share_token']); $externalShare->setRemote($storage['remote']); $externalShare->setName('irrelevant'); diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php index 1c19ad8f894..942c1769601 100644 --- a/apps/files_sharing/tests/External/ManagerTest.php +++ b/apps/files_sharing/tests/External/ManagerTest.php @@ -40,7 +40,6 @@ use OCP\IUserSession; use OCP\OCS\IDiscoveryService; use OCP\Server; use OCP\Share\IShare; -use OCP\Snowflake\ISnowflakeGenerator; use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; use Test\Traits\UserTrait; @@ -170,7 +169,6 @@ class ManagerTest extends TestCase { $this->setupManager, $this->certificateManager, $this->externalShareMapper, - Server::get(ISnowflakeGenerator::class), ] )->onlyMethods(['tryOCMEndPoint'])->getMock(); } @@ -190,7 +188,7 @@ class ManagerTest extends TestCase { public function testAddUserShare(): void { $userShare = new ExternalShare(); - $userShare->setId(Server::get(ISnowflakeGenerator::class)->nextId()); + $userShare->setId(); $userShare->setRemote('http://localhost'); $userShare->setShareToken('token1'); $userShare->setPassword(''); @@ -205,7 +203,7 @@ class ManagerTest extends TestCase { public function testAddGroupShare(): void { $groupShare = new ExternalShare(); - $groupShare->setId(Server::get(ISnowflakeGenerator::class)->nextId()); + $groupShare->setId(); $groupShare->setRemote('http://localhost'); $groupShare->setOwner('foobar'); $groupShare->setShareType(IShare::TYPE_GROUP); @@ -237,10 +235,10 @@ class ManagerTest extends TestCase { $shareData2 = $shareData1->clone(); $shareData2->setShareToken('token2'); - $shareData2->setId(\OCP\Server::get(ISnowflakeGenerator::class)->nextId()); + $shareData2->setId(); $shareData3 = $shareData1->clone(); $shareData3->setShareToken('token3'); - $shareData3->setId(\OCP\Server::get(ISnowflakeGenerator::class)->nextId()); + $shareData3->setId(); $this->setupMounts(); $this->assertNotMount('SharedFolder'); @@ -440,7 +438,7 @@ class ManagerTest extends TestCase { $user = $this->createMock(IUser::class); $user->expects($this->any())->method('getUID')->willReturn($userId); $share = new ExternalShare(); - $share->setId(Server::get(ISnowflakeGenerator::class)->nextId()); + $share->setId(); $share->setRemote('http://localhost'); $share->setShareToken('token1'); $share->setPassword(''); @@ -460,7 +458,7 @@ class ManagerTest extends TestCase { */ private function createTestGroupShare(string $groupId = 'group1'): array { $share = new ExternalShare(); - $share->setId(Server::get(ISnowflakeGenerator::class)->nextId()); + $share->setId(); $share->setRemote('http://localhost'); $share->setShareToken('token1'); $share->setPassword(''); @@ -646,7 +644,7 @@ class ManagerTest extends TestCase { // user 2 shares $manager2 = $this->createManagerForUser($user2); $share = new ExternalShare(); - $share->setId(Server::get(ISnowflakeGenerator::class)->nextId()); + $share->setId(); $share->setRemote('http://localhost'); $share->setShareToken('token1'); $share->setPassword(''); @@ -696,7 +694,7 @@ class ManagerTest extends TestCase { $manager2 = $this->createManagerForUser($user); $share = new ExternalShare(); - $share->setId(Server::get(ISnowflakeGenerator::class)->nextId()); + $share->setId(); $share->setRemote('http://localhost'); $share->setShareToken('token1'); $share->setPassword(''); diff --git a/core/BackgroundJobs/MovePreviewJob.php b/core/BackgroundJobs/MovePreviewJob.php index 6d461b89068..ce847a7a96f 100644 --- a/core/BackgroundJobs/MovePreviewJob.php +++ b/core/BackgroundJobs/MovePreviewJob.php @@ -26,7 +26,6 @@ use OCP\Files\IRootFolder; use OCP\IAppConfig; use OCP\IConfig; use OCP\IDBConnection; -use OCP\Snowflake\ISnowflakeGenerator; use Override; use Psr\Log\LoggerInterface; @@ -45,7 +44,6 @@ class MovePreviewJob extends TimedJob { private readonly IMimeTypeDetector $mimeTypeDetector, private readonly IMimeTypeLoader $mimeTypeLoader, private readonly LoggerInterface $logger, - private readonly ISnowflakeGenerator $generator, IAppDataFactory $appDataFactory, ) { parent::__construct($time); @@ -138,7 +136,7 @@ class MovePreviewJob extends TimedJob { $path = $fileId . '/' . $previewFile->getName(); /** @var SimpleFile $previewFile */ $preview = Preview::fromPath($path, $this->mimeTypeDetector); - $preview->setId($this->generator->nextId()); + $preview->setId(); if (!$preview) { $this->logger->error('Unable to import old preview at path.'); continue; @@ -172,6 +170,7 @@ class MovePreviewJob extends TimedJob { $preview->setStorageId($result[0]['storage']); $preview->setEtag($result[0]['etag']); $preview->setSourceMimeType($this->mimeTypeLoader->getMimetypeById((int)$result[0]['mimetype'])); + $preview->setId(); try { $preview = $this->previewMapper->insert($preview); } catch (Exception) { diff --git a/lib/private/Authentication/Token/PublicKeyToken.php b/lib/private/Authentication/Token/PublicKeyToken.php index be427ab4839..727496bff76 100644 --- a/lib/private/Authentication/Token/PublicKeyToken.php +++ b/lib/private/Authentication/Token/PublicKeyToken.php @@ -101,10 +101,6 @@ class PublicKeyToken extends Entity implements INamedToken, IWipeableToken { $this->addType('passwordInvalid', Types::BOOLEAN); } - public function getId(): int { - return $this->id; - } - public function getUID(): string { return $this->uid; } @@ -127,7 +123,7 @@ class PublicKeyToken extends Entity implements INamedToken, IWipeableToken { public function jsonSerialize(): array { return [ - 'id' => $this->id, + 'id' => $this->getId(), 'name' => $this->name, 'lastActivity' => $this->lastActivity, 'type' => $this->type, diff --git a/lib/private/Preview/Db/Preview.php b/lib/private/Preview/Db/Preview.php index d76435e23aa..fe2509158e8 100644 --- a/lib/private/Preview/Db/Preview.php +++ b/lib/private/Preview/Db/Preview.php @@ -11,14 +11,13 @@ declare(strict_types=1); namespace OC\Preview\Db; use OCP\AppFramework\Db\Entity; +use OCP\AppFramework\Db\SnowflakeAwareEntity; use OCP\DB\Types; use OCP\Files\IMimeTypeDetector; /** * Preview entity mapped to the oc_previews and oc_preview_locations table. * - * @method string getId() - * @method void setId(string $id) * @method int getFileId() Get the file id of the original file. * @method void setFileId(int $fileId) * @method int getStorageId() Get the storage id of the original file. @@ -55,7 +54,7 @@ use OCP\Files\IMimeTypeDetector; * * @see PreviewMapper */ -class Preview extends Entity { +class Preview extends SnowflakeAwareEntity { protected ?int $fileId = null; protected ?int $oldFileId = null; protected ?int $storageId = null; diff --git a/lib/private/Preview/Db/PreviewMapper.php b/lib/private/Preview/Db/PreviewMapper.php index 3b8cdd358e4..cf442e51691 100644 --- a/lib/private/Preview/Db/PreviewMapper.php +++ b/lib/private/Preview/Db/PreviewMapper.php @@ -52,15 +52,14 @@ class PreviewMapper extends QBMapper { if ($preview->getVersion() !== null && $preview->getVersion() !== '') { $qb = $this->db->getQueryBuilder(); - $id = $this->snowflake->nextId(); $qb->insert(self::VERSION_TABLE_NAME) ->values([ - 'id' => $qb->createNamedParameter($id), + 'id' => $qb->createNamedParameter($preview->getId()), 'version' => $qb->createNamedParameter($preview->getVersion(), IQueryBuilder::PARAM_STR), 'file_id' => $qb->createNamedParameter($preview->getFileId()), ]) ->executeStatement(); - $entity->setVersionId($id); + $entity->setVersionId((string)$preview->getId()); } return parent::insert($preview); } diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php index 42bcbf9c6e3..f0979185339 100644 --- a/lib/private/Preview/Generator.php +++ b/lib/private/Preview/Generator.php @@ -23,7 +23,6 @@ use OCP\IPreview; use OCP\IStreamImage; use OCP\Preview\BeforePreviewFetchedEvent; use OCP\Preview\IVersionedPreviewFile; -use OCP\Snowflake\ISnowflakeGenerator; use Psr\Log\LoggerInterface; class Generator { @@ -38,7 +37,6 @@ class Generator { private LoggerInterface $logger, private PreviewMapper $previewMapper, private StorageFactory $storageFactory, - private ISnowflakeGenerator $snowflakeGenerator, ) { } @@ -350,7 +348,7 @@ class Generator { try { $previewEntry = new Preview(); - $previewEntry->setId($this->snowflakeGenerator->nextId()); + $previewEntry->setId(); $previewEntry->setFileId($file->getId()); $previewEntry->setStorageId($file->getMountPoint()->getNumericStorageId()); $previewEntry->setSourceMimeType($file->getMimeType()); @@ -504,7 +502,7 @@ class Generator { } $previewEntry = new Preview(); - $previewEntry->setId($this->snowflakeGenerator->nextId()); + $previewEntry->setId(); $previewEntry->setFileId($file->getId()); $previewEntry->setStorageId($file->getMountPoint()->getNumericStorageId()); $previewEntry->setWidth($width); @@ -545,7 +543,7 @@ class Generator { throw new \RuntimeException('Unable to write preview file'); } $previewEntry->setSize($size); - + $previewEntry->setId(); return $this->previewMapper->insert($previewEntry); } } diff --git a/lib/private/Preview/Storage/LocalPreviewStorage.php b/lib/private/Preview/Storage/LocalPreviewStorage.php index 831382276ea..5d4c7a630dd 100644 --- a/lib/private/Preview/Storage/LocalPreviewStorage.php +++ b/lib/private/Preview/Storage/LocalPreviewStorage.php @@ -120,7 +120,7 @@ class LocalPreviewStorage implements IPreviewStorage { $this->logger->error('Unable to parse preview information for ' . $file->getRealPath()); continue; } - $preview->setId($this->generator->nextId()); + $preview->setId(); try { $preview->setSize($file->getSize()); $preview->setMtime($file->getMtime()); @@ -154,7 +154,7 @@ class LocalPreviewStorage implements IPreviewStorage { $preview->setStorageId($result[0]['storage']); $preview->setEtag($result[0]['etag']); $preview->setSourceMimetype($result[0]['mimetype']); - + $preview->setId(); // try to insert, if that fails the preview is already in the DB $this->previewMapper->insert($preview); diff --git a/lib/private/PreviewManager.php b/lib/private/PreviewManager.php index 86c86bcbe56..9684ad240e1 100644 --- a/lib/private/PreviewManager.php +++ b/lib/private/PreviewManager.php @@ -23,7 +23,6 @@ use OCP\IBinaryFinder; use OCP\IConfig; use OCP\IPreview; use OCP\Preview\IProviderV2; -use OCP\Snowflake\ISnowflakeGenerator; use Psr\Container\ContainerInterface; use Psr\Container\NotFoundExceptionInterface; use Psr\Log\LoggerInterface; @@ -142,7 +141,6 @@ class PreviewManager implements IPreview { $this->container->get(LoggerInterface::class), $this->container->get(PreviewMapper::class), $this->container->get(StorageFactory::class), - $this->container->get(ISnowflakeGenerator::class), ); } return $this->generator; diff --git a/lib/private/Settings/AuthorizedGroup.php b/lib/private/Settings/AuthorizedGroup.php index 0171e020171..a6039a66530 100644 --- a/lib/private/Settings/AuthorizedGroup.php +++ b/lib/private/Settings/AuthorizedGroup.php @@ -23,7 +23,7 @@ class AuthorizedGroup extends Entity implements \JsonSerializable { public function jsonSerialize(): array { return [ - 'id' => $this->id, + 'id' => $this->getId(), 'group_id' => $this->groupId, 'class' => $this->class ]; diff --git a/lib/private/Tags.php b/lib/private/Tags.php index 309d3739348..fb59fb670a6 100644 --- a/lib/private/Tags.php +++ b/lib/private/Tags.php @@ -290,7 +290,7 @@ class Tags implements ITags { return false; } $this->logger->debug(__METHOD__ . ' Added an tag with ' . $tag->getId(), ['app' => 'core']); - return $tag->getId(); + return $tag->getId() ?? false; } /** diff --git a/lib/public/Authentication/Token/IToken.php b/lib/public/Authentication/Token/IToken.php index 8c047280924..e3283ea9803 100644 --- a/lib/public/Authentication/Token/IToken.php +++ b/lib/public/Authentication/Token/IToken.php @@ -47,7 +47,7 @@ interface IToken extends JsonSerializable { * Get the token ID * @since 28.0.0 */ - public function getId(): int; + public function getId(): ?int; /** * Get the user UID diff --git a/tests/lib/Preview/GeneratorTest.php b/tests/lib/Preview/GeneratorTest.php index ee6b0ccb03a..ceaf483a658 100644 --- a/tests/lib/Preview/GeneratorTest.php +++ b/tests/lib/Preview/GeneratorTest.php @@ -22,7 +22,6 @@ use OCP\IPreview; use OCP\Preview\BeforePreviewFetchedEvent; use OCP\Preview\IProviderV2; use OCP\Preview\IVersionedPreviewFile; -use OCP\Snowflake\ISnowflakeGenerator; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\TestWith; use PHPUnit\Framework\MockObject\MockObject; @@ -42,7 +41,6 @@ class GeneratorTest extends TestCase { private LoggerInterface&MockObject $logger; private StorageFactory&MockObject $storageFactory; private PreviewMapper&MockObject $previewMapper; - private ISnowflakeGenerator&MockObject $snowflakeGenerator; protected function setUp(): void { parent::setUp(); @@ -54,7 +52,6 @@ class GeneratorTest extends TestCase { $this->logger = $this->createMock(LoggerInterface::class); $this->previewMapper = $this->createMock(PreviewMapper::class); $this->storageFactory = $this->createMock(StorageFactory::class); - $this->snowflakeGenerator = $this->createMock(ISnowflakeGenerator::class); $this->generator = new Generator( $this->config, @@ -64,7 +61,6 @@ class GeneratorTest extends TestCase { $this->logger, $this->previewMapper, $this->storageFactory, - $this->snowflakeGenerator, ); } diff --git a/tests/lib/Preview/PreviewMapperTest.php b/tests/lib/Preview/PreviewMapperTest.php index 9c379f27b2a..9436c379823 100644 --- a/tests/lib/Preview/PreviewMapperTest.php +++ b/tests/lib/Preview/PreviewMapperTest.php @@ -79,7 +79,7 @@ class PreviewMapperTest extends TestCase { $qb->executeStatement(); } $preview = new Preview(); - $preview->setId($this->snowflake->nextId()); + $preview->setId(); $preview->setFileId($fileId); $preview->setStorageId(1); $preview->setCropped(true); diff --git a/tests/lib/Preview/PreviewServiceTest.php b/tests/lib/Preview/PreviewServiceTest.php index cd86719d1c4..28e901f27c4 100644 --- a/tests/lib/Preview/PreviewServiceTest.php +++ b/tests/lib/Preview/PreviewServiceTest.php @@ -14,7 +14,6 @@ use OC\Preview\Db\Preview; use OC\Preview\Db\PreviewMapper; use OC\Preview\PreviewService; use OCP\Server; -use OCP\Snowflake\ISnowflakeGenerator; use PHPUnit\Framework\TestCase; #[CoversClass(PreviewService::class)] @@ -22,13 +21,11 @@ use PHPUnit\Framework\TestCase; class PreviewServiceTest extends TestCase { private PreviewService $previewService; private PreviewMapper $previewMapper; - private ISnowflakeGenerator $snowflakeGenerator; protected function setUp(): void { parent::setUp(); $this->previewService = Server::get(PreviewService::class); $this->previewMapper = Server::get(PreviewMapper::class); - $this->snowflakeGenerator = Server::get(ISnowflakeGenerator::class); $this->previewService->deleteAll(); } @@ -40,7 +37,6 @@ class PreviewServiceTest extends TestCase { public function testGetAvailableFileIds(): void { foreach (range(1, 20) as $i) { $preview = new Preview(); - $preview->setId($this->snowflakeGenerator->nextId()); $preview->setFileId($i % 10); $preview->setStorageId(1); $preview->setWidth($i);