diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index e3731ac3ecf02..8a2c12e0ac8bf 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -431,13 +431,7 @@ public function move(IShare $share, $recipient) { return $share; } - /** - * Get all children of this share - * - * @param IShare $parent - * @return IShare[] - */ - public function getChildren(IShare $parent) { + public function getChildren(IShare $parent): array { $children = []; $qb = $this->dbConnection->getQueryBuilder(); diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index 16a13786ea1fd..d28f7c51327a9 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -637,11 +637,6 @@ protected function generateToken(int $size = 15): string { return $token; } - /** - * Get all children of this share - * - * @return IShare[] - */ public function getChildren(IShare $parent): array { $children = []; diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index 44e54ae7f5467..5847d0138f3ed 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -4250,9 +4250,6 @@ getId()]]> - - - @@ -4261,9 +4258,6 @@ - - - diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index a2c0fd15eb4fc..29e7e2b575f99 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -127,9 +127,7 @@ public function create(\OCP\Share\IShare $share) { $qb->setValue('expiration', $qb->createNamedParameter($expirationDate, 'datetime')); } - if (method_exists($share, 'getParent')) { - $qb->setValue('parent', $qb->createNamedParameter($share->getParent())); - } + $qb->setValue('parent', $qb->createNamedParameter($share->getParent())); $qb->setValue('hide_download', $qb->createNamedParameter($share->getHideDownload() ? 1 : 0, IQueryBuilder::PARAM_INT)); } else { @@ -358,14 +356,7 @@ public function acceptShare(IShare $share, string $recipient): IShare { return $share; } - /** - * Get all children of this share - * FIXME: remove once https://github.com/owncloud/core/pull/21660 is in - * - * @param \OCP\Share\IShare $parent - * @return \OCP\Share\IShare[] - */ - public function getChildren(\OCP\Share\IShare $parent) { + public function getChildren(IShare $parent): array { $children = []; $qb = $this->dbConn->getQueryBuilder(); diff --git a/lib/private/Share20/LegacyHooks.php b/lib/private/Share20/LegacyHooks.php index 3bce0b9560ad3..d54c8e3203d17 100644 --- a/lib/private/Share20/LegacyHooks.php +++ b/lib/private/Share20/LegacyHooks.php @@ -82,7 +82,7 @@ private function formatHookParams(IShare $share) { 'itemSource' => $share->getNodeId(), 'shareType' => $shareType, 'shareWith' => $sharedWith, - 'itemparent' => method_exists($share, 'getParent') ? $share->getParent() : '', + 'itemparent' => $share->getParent(), 'uidOwner' => $share->getSharedBy(), 'fileSource' => $share->getNodeId(), 'fileTarget' => $share->getTarget() diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 9bfa810b10839..09b27da0a6879 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -580,13 +580,10 @@ protected function linkCreateChecks(IShare $share) { * @param IShare $share */ protected function setLinkParent(IShare $share) { - // No sense in checking if the method is not there. - if (method_exists($share, 'setParent')) { - $storage = $share->getNode()->getStorage(); - if ($storage->instanceOfStorage(SharedStorage::class)) { - /** @var \OCA\Files_Sharing\SharedStorage $storage */ - $share->setParent($storage->getShareId()); - } + $storage = $share->getNode()->getStorage(); + if ($storage->instanceOfStorage(SharedStorage::class)) { + /** @var \OCA\Files_Sharing\SharedStorage $storage */ + $share->setParent((int)$storage->getShareId()); } } @@ -1008,7 +1005,6 @@ private function setSharePasswordExpirationTime(IShare $share): void { /** * Delete all the children of this share - * FIXME: remove once https://github.com/owncloud/core/pull/21660 is in * * @param IShare $share * @return IShare[] List of deleted shares diff --git a/lib/private/Share20/Share.php b/lib/private/Share20/Share.php index 8caabb0898a4a..571efc8c4bef6 100644 --- a/lib/private/Share20/Share.php +++ b/lib/private/Share20/Share.php @@ -60,8 +60,7 @@ class Share implements IShare { private $sendPasswordByTalk = false; /** @var string */ private $token; - /** @var int */ - private $parent; + private ?int $parent = null; /** @var string */ private $target; /** @var \DateTime */ @@ -526,25 +525,12 @@ public function getToken() { return $this->token; } - /** - * Set the parent of this share - * - * @param int $parent - * @return IShare - * @deprecated 12.0.0 The new shares do not have parents. This is just here for legacy reasons. - */ - public function setParent($parent) { + public function setParent(int $parent): self { $this->parent = $parent; return $this; } - /** - * Get the parent of this share. - * - * @return int - * @deprecated 12.0.0 The new shares do not have parents. This is just here for legacy reasons. - */ - public function getParent() { + public function getParent(): ?int { return $this->parent; } diff --git a/lib/public/Share/IShare.php b/lib/public/Share/IShare.php index 5d8c64e131462..a1bdb01fcd29d 100644 --- a/lib/public/Share/IShare.php +++ b/lib/public/Share/IShare.php @@ -529,6 +529,20 @@ public function setToken($token); */ public function getToken(); + /** + * Set the parent of this share + * + * @since 9.0.0 + */ + public function setParent(int $parent): self; + + /** + * Get the parent of this share. + * + * @since 9.0.0 + */ + public function getParent(): ?int; + /** * Set the target path of this share relative to the recipients user folder. * diff --git a/lib/public/Share/IShareProvider.php b/lib/public/Share/IShareProvider.php index 9d7c8013a36ec..23187ca833ef4 100644 --- a/lib/public/Share/IShareProvider.php +++ b/lib/public/Share/IShareProvider.php @@ -208,4 +208,12 @@ public function getAccessList($nodes, $currentAccess); * @since 18.0.0 */ public function getAllShares(): iterable; + + /** + * Get all children of this share + * + * @return IShare[] + * @since 9.0.0 + */ + public function getChildren(IShare $parent); }