Skip to content

Commit 746e591

Browse files
committed
fix(IShare): Add missing getParent and setParent methods
Signed-off-by: provokateurin <[email protected]>
1 parent 665a385 commit 746e591

File tree

6 files changed

+23
-31
lines changed

6 files changed

+23
-31
lines changed

build/psalm-baseline.xml

Lines changed: 0 additions & 3 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>

lib/private/Share20/DefaultShareProvider.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@ public function create(\OCP\Share\IShare $share) {
127127
$qb->setValue('expiration', $qb->createNamedParameter($expirationDate, 'datetime'));
128128
}
129129

130-
if (method_exists($share, 'getParent')) {
131-
$qb->setValue('parent', $qb->createNamedParameter($share->getParent()));
132-
}
130+
$qb->setValue('parent', $qb->createNamedParameter($share->getParent()));
133131

134132
$qb->setValue('hide_download', $qb->createNamedParameter($share->getHideDownload() ? 1 : 0, IQueryBuilder::PARAM_INT));
135133
} else {

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 & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -580,13 +580,10 @@ protected function linkCreateChecks(IShare $share) {
580580
* @param IShare $share
581581
*/
582582
protected function setLinkParent(IShare $share) {
583-
// No sense in checking if the method is not there.
584-
if (method_exists($share, 'setParent')) {
585-
$storage = $share->getNode()->getStorage();
586-
if ($storage->instanceOfStorage(SharedStorage::class)) {
587-
/** @var \OCA\Files_Sharing\SharedStorage $storage */
588-
$share->setParent($storage->getShareId());
589-
}
583+
$storage = $share->getNode()->getStorage();
584+
if ($storage->instanceOfStorage(SharedStorage::class)) {
585+
/** @var \OCA\Files_Sharing\SharedStorage $storage */
586+
$share->setParent((int)$storage->getShareId());
590587
}
591588
}
592589

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
*

0 commit comments

Comments
 (0)