Skip to content

Commit

Permalink
Fix types of share related things
Browse files Browse the repository at this point in the history
Signed-off-by: jld3103 <jld3103yt@gmail.com>
  • Loading branch information
provokateurin committed Apr 3, 2023
1 parent 7ef9ef3 commit 6cecdc9
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 30 deletions.
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/ShareTypeList.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static function xmlDeserialize(Reader $reader) {
*/
public function xmlSerialize(Writer $writer) {
foreach ($this->shareTypes as $shareType) {
$writer->writeElement('{' . self::NS_OWNCLOUD . '}share-type', $shareType);
$writer->writeElement('{' . self::NS_OWNCLOUD . '}share-type', (string)$shareType);
}
}
}
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/ShareeList.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function xmlSerialize(Writer $writer) {
$writer->startElement('{' . self::NS_NEXTCLOUD . '}sharee');
$writer->writeElement('{' . self::NS_NEXTCLOUD . '}id', $share->getSharedWith());
$writer->writeElement('{' . self::NS_NEXTCLOUD . '}display-name', $share->getSharedWithDisplayName());
$writer->writeElement('{' . self::NS_NEXTCLOUD . '}type', $share->getShareType());
$writer->writeElement('{' . self::NS_NEXTCLOUD . '}type', (string)$share->getShareType());
$writer->endElement();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function createShare() {
$owner = isset($_POST['owner']) ? $_POST['owner'] : null;
$sharedBy = isset($_POST['sharedBy']) ? $_POST['sharedBy'] : null;
$shareWith = isset($_POST['shareWith']) ? $_POST['shareWith'] : null;
$remoteId = isset($_POST['remoteId']) ? (int)$_POST['remoteId'] : null;
$remoteId = isset($_POST['remoteId']) ? (string)($_POST['remoteId']) : null;
$sharedByFederatedId = isset($_POST['sharedByFederatedId']) ? $_POST['sharedByFederatedId'] : null;
$ownerFederatedId = isset($_POST['ownerFederatedId']) ? $_POST['ownerFederatedId'] : null;

Expand Down Expand Up @@ -186,7 +186,7 @@ public function createShare() {
*
* create re-share on behalf of another user
*
* @param int $id
* @param string $id
* @return Http\DataResponse
* @throws OCSBadRequestException
* @throws OCSException
Expand All @@ -195,13 +195,10 @@ public function createShare() {
public function reShare($id) {
$token = $this->request->getParam('token', null);
$shareWith = $this->request->getParam('shareWith', null);
$permission = (int)$this->request->getParam('permission', null);
$remoteId = (int)$this->request->getParam('remoteId', null);
$remoteId = $this->request->getParam('remoteId', null);

if ($id === null ||
$token === null ||
if ($token === null ||
$shareWith === null ||
$permission === null ||
$remoteId === null
) {
throw new OCSBadRequestException();
Expand All @@ -210,7 +207,7 @@ public function reShare($id) {
$notification = [
'sharedSecret' => $token,
'shareWith' => $shareWith,
'senderId' => $remoteId,
'senderId' => (int)$remoteId,
'message' => 'Recipient of a share ask the owner to reshare the file'
];

Expand Down Expand Up @@ -239,7 +236,7 @@ public function reShare($id) {
*
* accept server-to-server share
*
* @param int $id
* @param string $id
* @return Http\DataResponse
* @throws OCSException
* @throws ShareNotFound
Expand Down Expand Up @@ -274,7 +271,7 @@ public function acceptShare($id) {
*
* decline server-to-server share
*
* @param int $id
* @param string $id
* @return Http\DataResponse
* @throws OCSException
*/
Expand Down Expand Up @@ -307,7 +304,7 @@ public function declineShare($id) {
*
* remove server-to-server share if it was unshared by the owner
*
* @param int $id
* @param string $id
* @return Http\DataResponse
* @throws OCSException
*/
Expand Down Expand Up @@ -343,7 +340,7 @@ private function cleanupRemote($remote) {
*
* federated share was revoked, either by the owner or the re-sharer
*
* @param int $id
* @param string $id
* @return Http\DataResponse
* @throws OCSBadRequestException
*/
Expand Down Expand Up @@ -384,7 +381,7 @@ private function isS2SEnabled($incoming = false) {
*
* update share information to keep federated re-shares in sync
*
* @param int $id
* @param string $id
* @return Http\DataResponse
* @throws OCSBadRequestException
*/
Expand Down Expand Up @@ -437,7 +434,7 @@ protected function ncPermissions2ocmPermissions($ncPermissions) {
*
* change the owner of a server-to-server share
*
* @param int $id
* @param string $id
* @return Http\DataResponse
* @throws \InvalidArgumentException
* @throws OCSException
Expand Down
6 changes: 3 additions & 3 deletions apps/federatedfilesharing/lib/FederatedShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function create(IShare $share) {
if ($remoteShare) {
try {
$ownerCloudId = $this->cloudIdManager->getCloudId($remoteShare['owner'], $remoteShare['remote']);
$shareId = $this->addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ownerCloudId->getId(), $permissions, 'tmp_token_' . time(), $shareType, $expirationDate);
$shareId = (string)$this->addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ownerCloudId->getId(), $permissions, 'tmp_token_' . time(), $shareType, $expirationDate);
$share->setId($shareId);
[$token, $remoteId] = $this->askOwnerToReShare($shareWith, $share, $shareId);
// remote share was create successfully if we get a valid token as return
Expand Down Expand Up @@ -312,7 +312,7 @@ protected function createFederatedShare(IShare $share) {
}

if ($failure) {
$this->removeShareFromTableById($shareId);
$this->removeShareFromTableById((string)$shareId);
$message_t = $this->l->t('Sharing %1$s failed, could not find %2$s, maybe the server is currently unreachable or uses a self-signed certificate.',
[$share->getNode()->getName(), $share->getSharedWith()]);
throw new \Exception($message_t);
Expand Down Expand Up @@ -901,7 +901,7 @@ private function getRawShare($id) {
*/
private function createShareObject($data) {
$share = new Share($this->rootFolder, $this->userManager);
$share->setId((int)$data['id'])
$share->setId((string)$data['id'])
->setShareType((int)$data['share_type'])
->setPermissions((int)$data['permissions'])
->setTarget($data['file_target'])
Expand Down
2 changes: 1 addition & 1 deletion apps/federatedfilesharing/lib/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function __construct(
* @param string $token
* @param string $shareWith
* @param string $name
* @param string $remoteId
* @param int $remoteId
* @param string $owner
* @param string $ownerFederatedId
* @param string $sharedBy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ private function shareAccepted($id, array $notification) {

$token = $notification['sharedSecret'];

$share = $this->federatedShareProvider->getShareById($id);
$share = $this->federatedShareProvider->getShareById((int)$id);

$this->verifyShare($share, $token);
$this->executeAcceptShare($share);
Expand Down Expand Up @@ -448,7 +448,7 @@ protected function shareDeclined($id, array $notification) {

$token = $notification['sharedSecret'];

$share = $this->federatedShareProvider->getShareById($id);
$share = $this->federatedShareProvider->getShareById((int)$id);

$this->verifyShare($share, $token);

Expand Down Expand Up @@ -515,7 +515,7 @@ private function undoReshare($id, array $notification) {
}
$token = $notification['sharedSecret'];

$share = $this->federatedShareProvider->getShareById($id);
$share = $this->federatedShareProvider->getShareById((int)$id);

$this->verifyShare($share, $token);
$this->federatedShareProvider->removeShareFromTable($share);
Expand Down Expand Up @@ -637,7 +637,7 @@ protected function reshareRequested($id, array $notification) {
}
$senderId = $notification['senderId'];

$share = $this->federatedShareProvider->getShareById($id);
$share = $this->federatedShareProvider->getShareById((int)$id);

// We have to respect the default share permissions
$permissions = $share->getPermissions() & (int)$this->config->getAppValue('core', 'shareapi_default_permissions', (string)Constants::PERMISSION_ALL);
Expand Down
4 changes: 2 additions & 2 deletions apps/sharebymail/lib/ShareByMailProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ protected function addShareToDB(
* @return IShare The share object
*/
public function update(IShare $share, $plainTextPassword = null) {
$originalShare = $this->getShareById($share->getId());
$originalShare = $this->getShareById((int)$share->getId());

// a real password was given
$validPassword = $plainTextPassword !== null && $plainTextPassword !== '';
Expand Down Expand Up @@ -1029,7 +1029,7 @@ protected function removeShareFromTable(int $shareId): void {
*/
protected function createShareObject($data) {
$share = new Share($this->rootFolder, $this->userManager);
$share->setId((int)$data['id'])
$share->setId((string)$data['id'])
->setShareType((int)$data['share_type'])
->setPermissions((int)$data['permissions'])
->setTarget($data['file_target'])
Expand Down
6 changes: 3 additions & 3 deletions lib/private/Share20/DefaultShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public function create(\OCP\Share\IShare $share) {
* @throws \OCP\Files\NotFoundException
*/
public function update(\OCP\Share\IShare $share) {
$originalShare = $this->getShareById($share->getId());
$originalShare = $this->getShareById((int)$share->getId());

$shareAttributes = $this->formatShareAttributes($share->getAttributes());

Expand Down Expand Up @@ -593,7 +593,7 @@ public function restore(IShare $share, string $recipient): IShare {

$qb->execute();

return $this->getShareById($share->getId(), $recipient);
return $this->getShareById((int)$share->getId(), $recipient);
}

/**
Expand Down Expand Up @@ -1070,7 +1070,7 @@ public function getShareByToken($token) {
*/
private function createShare($data) {
$share = new Share($this->rootFolder, $this->userManager);
$share->setId((int)$data['id'])
$share->setId((string)$data['id'])
->setShareType((int)$data['share_type'])
->setPermissions((int)$data['permissions'])
->setTarget($data['file_target'])
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ public function getShareById($id, $recipient = null) {
throw new ShareNotFound();
}

$share = $provider->getShareById($id, $recipient);
$share = $provider->getShareById((int)$id, $recipient);

$this->checkExpireDate($share);

Expand Down

0 comments on commit 6cecdc9

Please sign in to comment.