Skip to content

Commit 49618b3

Browse files
Merge pull request #53946 from nextcloud/chore/remove-hierarchical-shares
2 parents 51dc9f8 + 746e591 commit 49618b3

File tree

9 files changed

+33
-55
lines changed

9 files changed

+33
-55
lines changed

apps/federatedfilesharing/lib/FederatedShareProvider.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -431,13 +431,7 @@ public function move(IShare $share, $recipient) {
431431
return $share;
432432
}
433433

434-
/**
435-
* Get all children of this share
436-
*
437-
* @param IShare $parent
438-
* @return IShare[]
439-
*/
440-
public function getChildren(IShare $parent) {
434+
public function getChildren(IShare $parent): array {
441435
$children = [];
442436

443437
$qb = $this->dbConnection->getQueryBuilder();

apps/sharebymail/lib/ShareByMailProvider.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -637,11 +637,6 @@ protected function generateToken(int $size = 15): string {
637637
return $token;
638638
}
639639

640-
/**
641-
* Get all children of this share
642-
*
643-
* @return IShare[]
644-
*/
645640
public function getChildren(IShare $parent): array {
646641
$children = [];
647642

build/psalm-baseline.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4250,9 +4250,6 @@
42504250
<code><![CDATA[$share->getId()]]></code>
42514251
<code><![CDATA[(int)$data['id']]]></code>
42524252
</InvalidArgument>
4253-
<UndefinedInterfaceMethod>
4254-
<code><![CDATA[getParent]]></code>
4255-
</UndefinedInterfaceMethod>
42564253
</file>
42574254
<file src="lib/private/Share20/Manager.php">
42584255
<InvalidArgument>
@@ -4261,9 +4258,6 @@
42614258
<UndefinedClass>
42624259
<code><![CDATA[\OCA\Circles\Api\v1\Circles]]></code>
42634260
</UndefinedClass>
4264-
<UndefinedInterfaceMethod>
4265-
<code><![CDATA[getChildren]]></code>
4266-
</UndefinedInterfaceMethod>
42674261
</file>
42684262
<file src="lib/private/Share20/ProviderFactory.php">
42694263
<InvalidReturnStatement>

lib/private/Share20/DefaultShareProvider.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ public function create(\OCP\Share\IShare $share) {
130130
$qb->setValue('expiration', $qb->createNamedParameter($expirationDate, 'datetime'));
131131
}
132132

133-
if (method_exists($share, 'getParent')) {
134-
$qb->setValue('parent', $qb->createNamedParameter($share->getParent()));
135-
}
133+
$qb->setValue('parent', $qb->createNamedParameter($share->getParent()));
136134

137135
$qb->setValue('hide_download', $qb->createNamedParameter($share->getHideDownload() ? 1 : 0, IQueryBuilder::PARAM_INT));
138136
} else {
@@ -361,14 +359,7 @@ public function acceptShare(IShare $share, string $recipient): IShare {
361359
return $share;
362360
}
363361

364-
/**
365-
* Get all children of this share
366-
* FIXME: remove once https://github.com/owncloud/core/pull/21660 is in
367-
*
368-
* @param \OCP\Share\IShare $parent
369-
* @return \OCP\Share\IShare[]
370-
*/
371-
public function getChildren(\OCP\Share\IShare $parent) {
362+
public function getChildren(IShare $parent): array {
372363
$children = [];
373364

374365
$qb = $this->dbConn->getQueryBuilder();

lib/private/Share20/LegacyHooks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private function formatHookParams(IShare $share) {
8282
'itemSource' => $share->getNodeId(),
8383
'shareType' => $shareType,
8484
'shareWith' => $sharedWith,
85-
'itemparent' => method_exists($share, 'getParent') ? $share->getParent() : '',
85+
'itemparent' => $share->getParent(),
8686
'uidOwner' => $share->getSharedBy(),
8787
'fileSource' => $share->getNodeId(),
8888
'fileTarget' => $share->getTarget()

lib/private/Share20/Manager.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -581,13 +581,10 @@ protected function linkCreateChecks(IShare $share) {
581581
* @param IShare $share
582582
*/
583583
protected function setLinkParent(IShare $share) {
584-
// No sense in checking if the method is not there.
585-
if (method_exists($share, 'setParent')) {
586-
$storage = $share->getNode()->getStorage();
587-
if ($storage->instanceOfStorage(SharedStorage::class)) {
588-
/** @var \OCA\Files_Sharing\SharedStorage $storage */
589-
$share->setParent($storage->getShareId());
590-
}
584+
$storage = $share->getNode()->getStorage();
585+
if ($storage->instanceOfStorage(SharedStorage::class)) {
586+
/** @var \OCA\Files_Sharing\SharedStorage $storage */
587+
$share->setParent((int)$storage->getShareId());
591588
}
592589
}
593590

@@ -1009,7 +1006,6 @@ private function setSharePasswordExpirationTime(IShare $share): void {
10091006

10101007
/**
10111008
* Delete all the children of this share
1012-
* FIXME: remove once https://github.com/owncloud/core/pull/21660 is in
10131009
*
10141010
* @param IShare $share
10151011
* @return IShare[] List of deleted shares

lib/private/Share20/Share.php

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ class Share implements IShare {
6060
private $sendPasswordByTalk = false;
6161
/** @var string */
6262
private $token;
63-
/** @var int */
64-
private $parent;
63+
private ?int $parent = null;
6564
/** @var string */
6665
private $target;
6766
/** @var \DateTime */
@@ -526,25 +525,12 @@ public function getToken() {
526525
return $this->token;
527526
}
528527

529-
/**
530-
* Set the parent of this share
531-
*
532-
* @param int $parent
533-
* @return IShare
534-
* @deprecated 12.0.0 The new shares do not have parents. This is just here for legacy reasons.
535-
*/
536-
public function setParent($parent) {
528+
public function setParent(int $parent): self {
537529
$this->parent = $parent;
538530
return $this;
539531
}
540532

541-
/**
542-
* Get the parent of this share.
543-
*
544-
* @return int
545-
* @deprecated 12.0.0 The new shares do not have parents. This is just here for legacy reasons.
546-
*/
547-
public function getParent() {
533+
public function getParent(): ?int {
548534
return $this->parent;
549535
}
550536

lib/public/Share/IShare.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,20 @@ public function setToken($token);
529529
*/
530530
public function getToken();
531531

532+
/**
533+
* Set the parent of this share
534+
*
535+
* @since 9.0.0
536+
*/
537+
public function setParent(int $parent): self;
538+
539+
/**
540+
* Get the parent of this share.
541+
*
542+
* @since 9.0.0
543+
*/
544+
public function getParent(): ?int;
545+
532546
/**
533547
* Set the target path of this share relative to the recipients user folder.
534548
*

lib/public/Share/IShareProvider.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,12 @@ public function getAccessList($nodes, $currentAccess);
208208
* @since 18.0.0
209209
*/
210210
public function getAllShares(): iterable;
211+
212+
/**
213+
* Get all children of this share
214+
*
215+
* @return IShare[]
216+
* @since 9.0.0
217+
*/
218+
public function getChildren(IShare $parent);
211219
}

0 commit comments

Comments
 (0)