From aefe8262023f5f3daaa33a33e6b31c8e12e33112 Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Thu, 3 Dec 2020 17:39:56 +0100 Subject: Adjust default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .../lib/FederatedShareProvider.php | 2 +- .../lib/Migration/Version1010Date20200630191755.php | 3 ++- .../lib/Migration/Version1011Date20201120125158.php | 18 ++++++++++++++++++ apps/federatedfilesharing/lib/Notifications.php | 8 ++++---- 4 files changed, 25 insertions(+), 6 deletions(-) (limited to 'apps/federatedfilesharing') diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index ffd76784bc3..0dc344ec9cf 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -493,7 +493,7 @@ class FederatedShareProvider implements IShareProvider { throw new ShareNotFound(); } - return (int)$data['remote_id']; + return (string)$data['remote_id']; } /** diff --git a/apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php b/apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php index 7376c8d9e73..afd41c20f64 100644 --- a/apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php +++ b/apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php @@ -48,8 +48,9 @@ class Version1010Date20200630191755 extends SimpleMigrationStep { 'notnull' => true, ]); $table->addColumn('remote_id', Types::STRING, [ - 'notnull' => true, + 'notnull' => false, 'length' => 255, + 'default' => '', ]); $table->setPrimaryKey(['share_id'], 'federated_res_pk'); // $table->addUniqueIndex(['share_id'], 'share_id_index'); diff --git a/apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php b/apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php index 1f32f2cced2..e89838c06f4 100644 --- a/apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php +++ b/apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php @@ -29,10 +29,19 @@ use Closure; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; use OCP\DB\ISchemaWrapper; +use OCP\IDBConnection; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; class Version1011Date20201120125158 extends SimpleMigrationStep { + + /** @var IDBConnection */ + private $connection; + + public function __construct(IDBConnection $connection) { + $this->connection = $connection; + } + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); @@ -41,6 +50,7 @@ class Version1011Date20201120125158 extends SimpleMigrationStep { $table = $schema->getTable('federated_reshares'); $remoteIdColumn = $table->getColumn('remote_id'); if ($remoteIdColumn && $remoteIdColumn->getType()->getName() !== Types::STRING) { + $remoteIdColumn->setNotnull(false); $remoteIdColumn->setType(Type::getType(Types::STRING)); $remoteIdColumn->setOptions(['length' => 255]); $remoteIdColumn->setDefault(''); @@ -50,4 +60,12 @@ class Version1011Date20201120125158 extends SimpleMigrationStep { return null; } + + public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { + $qb = $this->connection->getQueryBuilder(); + $qb->update('federated_reshares') + ->set('remote_id', $qb->createNamedParameter('')) + ->where($qb->expr()->eq('remote_id', $qb->createNamedParameter('-1'))); + $qb->execute(); + } } diff --git a/apps/federatedfilesharing/lib/Notifications.php b/apps/federatedfilesharing/lib/Notifications.php index 63acc648d51..c683c8de8b3 100644 --- a/apps/federatedfilesharing/lib/Notifications.php +++ b/apps/federatedfilesharing/lib/Notifications.php @@ -133,12 +133,12 @@ class Notifications { * * @param string $token * @param string $id remote Id - * @param int $shareId internal share Id + * @param string $shareId internal share Id * @param string $remote remote address of the owner * @param string $shareWith * @param int $permission * @param string $filename - * @return array + * @return array|false * @throws \OC\HintException * @throws \OC\ServerNotAvailableException */ @@ -182,7 +182,7 @@ class Notifications { * send server-to-server unshare to remote server * * @param string $remote url - * @param int $id share id + * @param string $id share id * @param string $token * @return bool */ @@ -194,7 +194,7 @@ class Notifications { * send server-to-server unshare to remote server * * @param string $remote url - * @param int $id share id + * @param string $id share id * @param string $token * @return bool */ -- cgit v1.2.3