Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions apps/federatedfilesharing/lib/FederatedShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 0 additions & 5 deletions apps/sharebymail/lib/ShareByMailProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

Expand Down
6 changes: 0 additions & 6 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -4261,9 +4258,6 @@
<UndefinedClass>
<code><![CDATA[\OCA\Circles\Api\v1\Circles]]></code>
</UndefinedClass>
<UndefinedInterfaceMethod>
<code><![CDATA[getChildren]]></code>
</UndefinedInterfaceMethod>
</file>
<file src="lib/private/Share20/ProviderFactory.php">
<InvalidReturnStatement>
Expand Down
13 changes: 2 additions & 11 deletions lib/private/Share20/DefaultShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Share20/LegacyHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 4 additions & 8 deletions lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -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
Expand Down
20 changes: 3 additions & 17 deletions lib/private/Share20/Share.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
}

Expand Down
14 changes: 14 additions & 0 deletions lib/public/Share/IShare.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
8 changes: 8 additions & 0 deletions lib/public/Share/IShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Loading