diff --git a/apps/federatedfilesharing/appinfo/Migrations/Version20190410160725.php b/apps/federatedfilesharing/appinfo/Migrations/Version20190410160725.php
new file mode 100644
index 000000000000..e3423044fb57
--- /dev/null
+++ b/apps/federatedfilesharing/appinfo/Migrations/Version20190410160725.php
@@ -0,0 +1,32 @@
+hasTable("${prefix}federated_reshares")) {
+ $table = $schema->getTable("{$prefix}federated_reshares");
+ $remoteIdColumn = $table->getColumn('remote_id');
+ if ($remoteIdColumn && $remoteIdColumn->getType()->getName() !== Type::STRING) {
+ $remoteIdColumn->setType(Type::getType(Type::STRING));
+ $remoteIdColumn->setOptions(['length' => 255]);
+ }
+ }
+
+ if ($schema->hasTable("${prefix}share_external")) {
+ $table = $schema->getTable("{$prefix}share_external");
+ $remoteIdColumn = $table->getColumn('remote_id');
+ if ($remoteIdColumn && $remoteIdColumn->getType()->getName() !== Type::STRING) {
+ $remoteIdColumn->setType(Type::getType(Type::STRING));
+ $remoteIdColumn->setOptions(['length' => 255]);
+ }
+ }
+ }
+}
diff --git a/apps/federatedfilesharing/appinfo/info.xml b/apps/federatedfilesharing/appinfo/info.xml
index 83be1d798644..45ccca83c4f5 100644
--- a/apps/federatedfilesharing/appinfo/info.xml
+++ b/apps/federatedfilesharing/appinfo/info.xml
@@ -5,7 +5,7 @@
Provide federated file sharing across ownCloud servers
AGPL
Bjoern Schiessle, Roeland Jago Douma
- 0.4.0
+ 0.5.0
FederatedFileSharing
true
other
diff --git a/apps/federatedfilesharing/lib/FedShareManager.php b/apps/federatedfilesharing/lib/FedShareManager.php
index c7c7d99513d3..7f904854598f 100644
--- a/apps/federatedfilesharing/lib/FedShareManager.php
+++ b/apps/federatedfilesharing/lib/FedShareManager.php
@@ -116,7 +116,7 @@ public function __construct(FederatedShareProvider $federatedShareProvider,
* @param Address $ownerAddress
* @param Address $sharedByAddress
* @param string $shareWith
- * @param int $remoteId
+ * @param string $remoteId
* @param string $name
* @param string $token
*
@@ -181,7 +181,7 @@ public function createShare(Address $ownerAddress,
/**
* @param IShare $share
- * @param int $remoteId
+ * @param string $remoteId
* @param string $shareWith
* @param int|null $permissions - null for OCM 1.0-proposal1
*
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index 70393a2e0190..f80fa3b1efbf 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -302,7 +302,7 @@ protected function getShareFromExternalShareTable(IShare $share) {
->andWhere($query->expr()->eq('mountpoint', $query->createNamedParameter($share->getTarget())));
$result = $query->execute()->fetchAll();
- if (isset($result[0]) && (int)$result[0]['remote_id'] > 0) {
+ if (isset($result[0]) && $result[0]['remote_id'] !== "") {
return $result[0];
}
@@ -427,7 +427,7 @@ public function storeRemoteId($shareId, $remoteId) {
* get share ID on remote server for federated re-shares
*
* @param IShare $share
- * @return int
+ * @return string
* @throws ShareNotFound
*/
public function getRemoteId(IShare $share) {
@@ -440,7 +440,7 @@ public function getRemoteId(IShare $share) {
throw new ShareNotFound();
}
- return (int)$data['remote_id'];
+ return $data['remote_id'];
}
/**
@@ -975,7 +975,7 @@ public function updateForRecipient(IShare $share, $recipient) {
}
/**
- * @param int $remoteId
+ * @param string $remoteId
* @param string $shareToken
* @return mixed
*/
diff --git a/apps/federatedfilesharing/lib/Notifications.php b/apps/federatedfilesharing/lib/Notifications.php
index 3a1bc0e64ead..92df22ccdd75 100644
--- a/apps/federatedfilesharing/lib/Notifications.php
+++ b/apps/federatedfilesharing/lib/Notifications.php
@@ -83,7 +83,7 @@ public function __construct(
* @param Address $sharedByAddress
* @param string $token
* @param string $name
- * @param int $remote_id
+ * @param string $remote_id
*
* @return bool
*
@@ -148,7 +148,7 @@ public function requestReShare($token, $id, $shareId, $remote, $shareWith, $perm
if (\is_array($response) && isset($response['sharedSecret'], $response['providerId'])) {
return [
$response['sharedSecret'],
- (int) $response['providerId']
+ $response['providerId']
];
}
return true;
@@ -172,7 +172,7 @@ public function requestReShare($token, $id, $shareId, $remote, $shareWith, $perm
if ($httpRequestSuccessful && $this->isOcsStatusOk($status) && $validToken && $validRemoteId) {
return [
$status['ocs']['data']['token'],
- (int)$status['ocs']['data']['remoteId']
+ $status['ocs']['data']['remoteId']
];
}
@@ -207,7 +207,7 @@ public function sendRevokeShare($remote, $id, $token) {
* send notification to remote server if the permissions was changed
*
* @param string $remote
- * @param int $remoteId
+ * @param string $remoteId
* @param string $token
* @param int $permissions
* @return bool
@@ -220,7 +220,7 @@ public function sendPermissionChange($remote, $remoteId, $token, $permissions) {
* forward accept reShare to remote server
*
* @param string $remote
- * @param int $remoteId
+ * @param string $remoteId
* @param string $token
*/
public function sendAcceptShare($remote, $remoteId, $token) {
@@ -231,7 +231,7 @@ public function sendAcceptShare($remote, $remoteId, $token) {
* forward decline reShare to remote server
*
* @param string $remote
- * @param int $remoteId
+ * @param string $remoteId
* @param string $token
*/
public function sendDeclineShare($remote, $remoteId, $token) {
@@ -242,7 +242,7 @@ public function sendDeclineShare($remote, $remoteId, $token) {
* inform remote server whether server-to-server share was accepted/declined
*
* @param string $remote
- * @param int $remoteId Share id on the remote host
+ * @param string $remoteId Share id on the remote host
* @param string $token
* @param string $action possible actions:
* accept, decline, unshare, revoke, permissions
@@ -371,7 +371,7 @@ protected function sendOcmRemoteShare(Address $shareWithAddress, Address $ownerA
$fields = [
'shareWith' => $shareWithAddress->getCloudId(),
'name' => $name,
- 'providerId' => $remote_id,
+ 'providerId' => (string) $remote_id,
'owner' => $ownerAddress->getCloudId(),
'ownerDisplayName' => $ownerAddress->getDisplayName(),
'sender' => $sharedByAddress->getCloudId(),
diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
index ee0a66eef616..e805b9afaa83 100644
--- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
+++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
@@ -24,11 +24,14 @@
*/
namespace OCA\FederatedFileSharing\Tests;
+use Doctrine\DBAL\Driver\Statement;
use OCA\FederatedFileSharing\Address;
use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\FederatedFileSharing\Notifications;
use OCA\FederatedFileSharing\TokenHandler;
+use OCP\DB\QueryBuilder\IExpressionBuilder;
+use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Files\IRootFolder;
use OCP\IConfig;
use OCP\IDBConnection;
@@ -945,4 +948,38 @@ public function dataTestGetAccepted() {
[false, 'yes', 'yes', true, true],
];
}
+
+ public function testGetRemoteId() {
+ $exprBuilder = $this->createMock(IExpressionBuilder::class);
+ $statementMock = $this->createMock(Statement::class);
+ $statementMock->method('fetch')->willReturn(['remote_id' => 'a0b0c0']);
+
+ $qbMock = $this->createMock(IQueryBuilder::class);
+ $qbMock->method('select')->willReturnSelf();
+ $qbMock->method('from')->willReturnSelf();
+ $qbMock->method('where')->willReturnSelf();
+ $qbMock->method('expr')->willReturn($exprBuilder);
+ $qbMock->method('execute')->willReturn($statementMock);
+ $connectionMock = $this->createMock(IDBConnection::class);
+ $connectionMock->method('getQueryBuilder')->willReturn($qbMock);
+
+ $shareMock = $this->createMock(IShare::class);
+ $this->provider = new FederatedShareProvider(
+ $connectionMock,
+ $this->eventDispatcher,
+ $this->addressHandler,
+ $this->notifications,
+ $this->tokenHandler,
+ $this->l,
+ $this->logger,
+ $this->rootFolder,
+ $this->config,
+ $this->userManager
+ );
+
+ $this->assertEquals(
+ 'a0b0c0',
+ $this->provider->getRemoteId($shareMock)
+ );
+ }
}
diff --git a/apps/federatedfilesharing/tests/appinfo/Migrations/Version20190410160725Test.php b/apps/federatedfilesharing/tests/appinfo/Migrations/Version20190410160725Test.php
new file mode 100644
index 000000000000..871d4fd9c401
--- /dev/null
+++ b/apps/federatedfilesharing/tests/appinfo/Migrations/Version20190410160725Test.php
@@ -0,0 +1,30 @@
+createMock(Table::class);
+ $schema = $this->createMock(Schema::class);
+ $schema->method('hasTable')->withConsecutive(
+ ['pr_federated_reshares'],
+ ['pr_share_external']
+ )->willReturn(true);
+ $schema->method('getTable')->withConsecutive(
+ ['pr_federated_reshares'],
+ ['pr_share_external']
+ )->willReturn($table);
+
+ $this->assertNull($migration->changeSchema($schema, ['tablePrefix' => $tablePrefix]));
+ }
+}
diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php
index 4a411cad15d8..105cebc7a32a 100644
--- a/apps/files_sharing/lib/External/Manager.php
+++ b/apps/files_sharing/lib/External/Manager.php
@@ -103,7 +103,7 @@ public function __construct(\OCP\IDBConnection $connection,
* @param string $owner
* @param boolean $accepted
* @param string $user
- * @param int $remoteId
+ * @param string $remoteId
* @return Mount|null
*/
public function addShare($remote, $token, $password, $name, $owner, $accepted=false, $user = null, $remoteId = -1) {
diff --git a/lib/public/Share/Events/ShareEvent.php b/lib/public/Share/Events/ShareEvent.php
index 34182b9b826f..a06836594b59 100644
--- a/lib/public/Share/Events/ShareEvent.php
+++ b/lib/public/Share/Events/ShareEvent.php
@@ -62,11 +62,11 @@ public function getRemote() {
}
/**
- * @return int
+ * @return string
* @since 10.0.2
*/
public function getRemoteId() {
- return (int)$this->share['remote_id'];
+ return $this->share['remote_id'];
}
/**