fix(IShare): Add missing getParent and setParent methods

Signed-off-by: provokateurin <kate@provokateurin.de>
pull/53946/head
provokateurin 2025-07-22 13:10:45 +07:00
parent 665a38573c
commit 746e5917c7
No known key found for this signature in database
6 changed files with 23 additions and 31 deletions

@ -4250,9 +4250,6 @@
<code><![CDATA[$share->getId()]]></code>
<code><![CDATA[(int)$data['id']]]></code>
</InvalidArgument>
<UndefinedInterfaceMethod>
<code><![CDATA[getParent]]></code>
</UndefinedInterfaceMethod>
</file>
<file src="lib/private/Share20/Manager.php">
<InvalidArgument>

@ -127,9 +127,7 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv
$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 {

@ -82,7 +82,7 @@ class LegacyHooks {
'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()

@ -580,13 +580,10 @@ class Manager implements IManager {
* @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());
}
}

@ -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 @@ class Share implements IShare {
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;
}

@ -529,6 +529,20 @@ interface IShare {
*/
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.
*