Skip to content

Commit ccafe85

Browse files
committed
Fix types of share related things
Signed-off-by: jld3103 <jld3103yt@gmail.com>
1 parent 5da480a commit ccafe85

File tree

9 files changed

+34
-37
lines changed

9 files changed

+34
-37
lines changed

apps/dav/lib/Connector/Sabre/ShareTypeList.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static function xmlDeserialize(Reader $reader) {
8686
*/
8787
public function xmlSerialize(Writer $writer) {
8888
foreach ($this->shareTypes as $shareType) {
89-
$writer->writeElement('{' . self::NS_OWNCLOUD . '}share-type', $shareType);
89+
$writer->writeElement('{' . self::NS_OWNCLOUD . '}share-type', (string)$shareType);
9090
}
9191
}
9292
}

apps/dav/lib/Connector/Sabre/ShareeList.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function xmlSerialize(Writer $writer) {
5555
$writer->startElement('{' . self::NS_NEXTCLOUD . '}sharee');
5656
$writer->writeElement('{' . self::NS_NEXTCLOUD . '}id', $share->getSharedWith());
5757
$writer->writeElement('{' . self::NS_NEXTCLOUD . '}display-name', $share->getSharedWithDisplayName());
58-
$writer->writeElement('{' . self::NS_NEXTCLOUD . '}type', $share->getShareType());
58+
$writer->writeElement('{' . self::NS_NEXTCLOUD . '}type', (string)$share->getShareType());
5959
$writer->endElement();
6060
}
6161
}

apps/federatedfilesharing/lib/Controller/RequestHandlerController.php

+18-21
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function createShare() {
134134
$owner = isset($_POST['owner']) ? $_POST['owner'] : null;
135135
$sharedBy = isset($_POST['sharedBy']) ? $_POST['sharedBy'] : null;
136136
$shareWith = isset($_POST['shareWith']) ? $_POST['shareWith'] : null;
137-
$remoteId = isset($_POST['remoteId']) ? (int)$_POST['remoteId'] : null;
137+
$remoteId = isset($_POST['remoteId']) ? (string)$_POST['remoteId'] : null;
138138
$sharedByFederatedId = isset($_POST['sharedByFederatedId']) ? $_POST['sharedByFederatedId'] : null;
139139
$ownerFederatedId = isset($_POST['ownerFederatedId']) ? $_POST['ownerFederatedId'] : null;
140140

@@ -186,22 +186,19 @@ public function createShare() {
186186
*
187187
* create re-share on behalf of another user
188188
*
189-
* @param int $id
189+
* @param string $id
190190
* @return Http\DataResponse
191191
* @throws OCSBadRequestException
192192
* @throws OCSException
193193
* @throws OCSForbiddenException
194194
*/
195-
public function reShare($id) {
195+
public function reShare(string $id) {
196196
$token = $this->request->getParam('token', null);
197197
$shareWith = $this->request->getParam('shareWith', null);
198-
$permission = (int)$this->request->getParam('permission', null);
199-
$remoteId = (int)$this->request->getParam('remoteId', null);
198+
$remoteId = $this->request->getParam('remoteId', null);
200199

201-
if ($id === null ||
202-
$token === null ||
200+
if ($token === null ||
203201
$shareWith === null ||
204-
$permission === null ||
205202
$remoteId === null
206203
) {
207204
throw new OCSBadRequestException();
@@ -210,7 +207,7 @@ public function reShare($id) {
210207
$notification = [
211208
'sharedSecret' => $token,
212209
'shareWith' => $shareWith,
213-
'senderId' => $remoteId,
210+
'senderId' => (int)$remoteId,
214211
'message' => 'Recipient of a share ask the owner to reshare the file'
215212
];
216213

@@ -239,13 +236,13 @@ public function reShare($id) {
239236
*
240237
* accept server-to-server share
241238
*
242-
* @param int $id
239+
* @param string $id
243240
* @return Http\DataResponse
244241
* @throws OCSException
245242
* @throws ShareNotFound
246243
* @throws \OCP\HintException
247244
*/
248-
public function acceptShare($id) {
245+
public function acceptShare(string $id) {
249246
$token = isset($_POST['token']) ? $_POST['token'] : null;
250247

251248
$notification = [
@@ -274,11 +271,11 @@ public function acceptShare($id) {
274271
*
275272
* decline server-to-server share
276273
*
277-
* @param int $id
274+
* @param string $id
278275
* @return Http\DataResponse
279276
* @throws OCSException
280277
*/
281-
public function declineShare($id) {
278+
public function declineShare(string $id) {
282279
$token = isset($_POST['token']) ? $_POST['token'] : null;
283280

284281
$notification = [
@@ -307,11 +304,11 @@ public function declineShare($id) {
307304
*
308305
* remove server-to-server share if it was unshared by the owner
309306
*
310-
* @param int $id
307+
* @param string $id
311308
* @return Http\DataResponse
312309
* @throws OCSException
313310
*/
314-
public function unshare($id) {
311+
public function unshare(string $id) {
315312
if (!$this->isS2SEnabled()) {
316313
throw new OCSException('Server does not support federated cloud sharing', 503);
317314
}
@@ -343,11 +340,11 @@ private function cleanupRemote($remote) {
343340
*
344341
* federated share was revoked, either by the owner or the re-sharer
345342
*
346-
* @param int $id
343+
* @param string $id
347344
* @return Http\DataResponse
348345
* @throws OCSBadRequestException
349346
*/
350-
public function revoke($id) {
347+
public function revoke(string $id) {
351348
$token = $this->request->getParam('token');
352349

353350
try {
@@ -384,11 +381,11 @@ private function isS2SEnabled($incoming = false) {
384381
*
385382
* update share information to keep federated re-shares in sync
386383
*
387-
* @param int $id
384+
* @param string $id
388385
* @return Http\DataResponse
389386
* @throws OCSBadRequestException
390387
*/
391-
public function updatePermissions($id) {
388+
public function updatePermissions(string $id) {
392389
$token = $this->request->getParam('token', null);
393390
$ncPermissions = $this->request->getParam('permissions', null);
394391

@@ -437,12 +434,12 @@ protected function ncPermissions2ocmPermissions($ncPermissions) {
437434
*
438435
* change the owner of a server-to-server share
439436
*
440-
* @param int $id
437+
* @param string $id
441438
* @return Http\DataResponse
442439
* @throws \InvalidArgumentException
443440
* @throws OCSException
444441
*/
445-
public function move($id) {
442+
public function move(string $id) {
446443
if (!$this->isS2SEnabled()) {
447444
throw new OCSException('Server does not support federated cloud sharing', 503);
448445
}

apps/federatedfilesharing/lib/FederatedShareProvider.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function create(IShare $share) {
229229
if ($remoteShare) {
230230
try {
231231
$ownerCloudId = $this->cloudIdManager->getCloudId($remoteShare['owner'], $remoteShare['remote']);
232-
$shareId = $this->addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ownerCloudId->getId(), $permissions, 'tmp_token_' . time(), $shareType, $expirationDate);
232+
$shareId = (string)$this->addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $ownerCloudId->getId(), $permissions, 'tmp_token_' . time(), $shareType, $expirationDate);
233233
$share->setId($shareId);
234234
[$token, $remoteId] = $this->askOwnerToReShare($shareWith, $share, $shareId);
235235
// remote share was create successfully if we get a valid token as return
@@ -312,7 +312,7 @@ protected function createFederatedShare(IShare $share) {
312312
}
313313

314314
if ($failure) {
315-
$this->removeShareFromTableById($shareId);
315+
$this->removeShareFromTableById((string)$shareId);
316316
$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.',
317317
[$share->getNode()->getName(), $share->getSharedWith()]);
318318
throw new \Exception($message_t);
@@ -901,7 +901,7 @@ private function getRawShare($id) {
901901
*/
902902
private function createShareObject($data) {
903903
$share = new Share($this->rootFolder, $this->userManager);
904-
$share->setId((int)$data['id'])
904+
$share->setId((string)$data['id'])
905905
->setShareType((int)$data['share_type'])
906906
->setPermissions((int)$data['permissions'])
907907
->setTarget($data['file_target'])

apps/federatedfilesharing/lib/Notifications.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function __construct(
9090
* @param string $token
9191
* @param string $shareWith
9292
* @param string $name
93-
* @param string $remoteId
93+
* @param int $remoteId
9494
* @param string $owner
9595
* @param string $ownerFederatedId
9696
* @param string $sharedBy

apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ private function shareAccepted($id, array $notification) {
378378

379379
$token = $notification['sharedSecret'];
380380

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

383383
$this->verifyShare($share, $token);
384384
$this->executeAcceptShare($share);
@@ -448,7 +448,7 @@ protected function shareDeclined($id, array $notification) {
448448

449449
$token = $notification['sharedSecret'];
450450

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

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

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

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

520520
$this->verifyShare($share, $token);
521521
$this->federatedShareProvider->removeShareFromTable($share);
@@ -637,7 +637,7 @@ protected function reshareRequested($id, array $notification) {
637637
}
638638
$senderId = $notification['senderId'];
639639

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

642642
// We have to respect the default share permissions
643643
$permissions = $share->getPermissions() & (int)$this->config->getAppValue('core', 'shareapi_default_permissions', (string)Constants::PERMISSION_ALL);

apps/sharebymail/lib/ShareByMailProvider.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ protected function addShareToDB(
758758
* @return IShare The share object
759759
*/
760760
public function update(IShare $share, $plainTextPassword = null) {
761-
$originalShare = $this->getShareById($share->getId());
761+
$originalShare = $this->getShareById((int)$share->getId());
762762

763763
// a real password was given
764764
$validPassword = $plainTextPassword !== null && $plainTextPassword !== '';
@@ -1029,7 +1029,7 @@ protected function removeShareFromTable(int $shareId): void {
10291029
*/
10301030
protected function createShareObject($data) {
10311031
$share = new Share($this->rootFolder, $this->userManager);
1032-
$share->setId((int)$data['id'])
1032+
$share->setId((string)$data['id'])
10331033
->setShareType((int)$data['share_type'])
10341034
->setPermissions((int)$data['permissions'])
10351035
->setTarget($data['file_target'])

lib/private/Share20/DefaultShareProvider.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public function create(\OCP\Share\IShare $share) {
255255
* @throws \OCP\Files\NotFoundException
256256
*/
257257
public function update(\OCP\Share\IShare $share) {
258-
$originalShare = $this->getShareById($share->getId());
258+
$originalShare = $this->getShareById((int)$share->getId());
259259

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

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

594594
$qb->execute();
595595

596-
return $this->getShareById($share->getId(), $recipient);
596+
return $this->getShareById((int)$share->getId(), $recipient);
597597
}
598598

599599
/**
@@ -1070,7 +1070,7 @@ public function getShareByToken($token) {
10701070
*/
10711071
private function createShare($data) {
10721072
$share = new Share($this->rootFolder, $this->userManager);
1073-
$share->setId((int)$data['id'])
1073+
$share->setId((string)$data['id'])
10741074
->setShareType((int)$data['share_type'])
10751075
->setPermissions((int)$data['permissions'])
10761076
->setTarget($data['file_target'])

lib/private/Share20/Manager.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,7 @@ public function getShareById($id, $recipient = null) {
14511451
throw new ShareNotFound();
14521452
}
14531453

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

14561456
$this->checkExpireDate($share);
14571457

0 commit comments

Comments
 (0)