diff --git a/apps/federatedfilesharing/appinfo/info.xml b/apps/federatedfilesharing/appinfo/info.xml index b30656fa51..05badd3bd7 100644 --- a/apps/federatedfilesharing/appinfo/info.xml +++ b/apps/federatedfilesharing/appinfo/info.xml @@ -5,7 +5,7 @@ Federated file sharing Provide federated file sharing across servers Provide federated file sharing across servers - 1.10.1 + 1.10.2 agpl Bjoern Schiessle Roeland Jago Douma diff --git a/apps/federatedfilesharing/composer/composer/autoload_classmap.php b/apps/federatedfilesharing/composer/composer/autoload_classmap.php index 8d1364c0d6..0b07303e71 100644 --- a/apps/federatedfilesharing/composer/composer/autoload_classmap.php +++ b/apps/federatedfilesharing/composer/composer/autoload_classmap.php @@ -15,6 +15,7 @@ return array( 'OCA\\FederatedFileSharing\\FederatedShareProvider' => $baseDir . '/../lib/FederatedShareProvider.php', 'OCA\\FederatedFileSharing\\Listeners\\LoadAdditionalScriptsListener' => $baseDir . '/../lib/Listeners/LoadAdditionalScriptsListener.php', 'OCA\\FederatedFileSharing\\Migration\\Version1010Date20200630191755' => $baseDir . '/../lib/Migration/Version1010Date20200630191755.php', + 'OCA\\FederatedFileSharing\\Migration\\Version1011Date20201120125158' => $baseDir . '/../lib/Migration/Version1011Date20201120125158.php', 'OCA\\FederatedFileSharing\\Notifications' => $baseDir . '/../lib/Notifications.php', 'OCA\\FederatedFileSharing\\Notifier' => $baseDir . '/../lib/Notifier.php', 'OCA\\FederatedFileSharing\\OCM\\CloudFederationProviderFiles' => $baseDir . '/../lib/OCM/CloudFederationProviderFiles.php', diff --git a/apps/federatedfilesharing/composer/composer/autoload_static.php b/apps/federatedfilesharing/composer/composer/autoload_static.php index 6e352d6f32..97ff383b90 100644 --- a/apps/federatedfilesharing/composer/composer/autoload_static.php +++ b/apps/federatedfilesharing/composer/composer/autoload_static.php @@ -30,6 +30,7 @@ class ComposerStaticInitFederatedFileSharing 'OCA\\FederatedFileSharing\\FederatedShareProvider' => __DIR__ . '/..' . '/../lib/FederatedShareProvider.php', 'OCA\\FederatedFileSharing\\Listeners\\LoadAdditionalScriptsListener' => __DIR__ . '/..' . '/../lib/Listeners/LoadAdditionalScriptsListener.php', 'OCA\\FederatedFileSharing\\Migration\\Version1010Date20200630191755' => __DIR__ . '/..' . '/../lib/Migration/Version1010Date20200630191755.php', + 'OCA\\FederatedFileSharing\\Migration\\Version1011Date20201120125158' => __DIR__ . '/..' . '/../lib/Migration/Version1011Date20201120125158.php', 'OCA\\FederatedFileSharing\\Notifications' => __DIR__ . '/..' . '/../lib/Notifications.php', 'OCA\\FederatedFileSharing\\Notifier' => __DIR__ . '/..' . '/../lib/Notifier.php', 'OCA\\FederatedFileSharing\\OCM\\CloudFederationProviderFiles' => __DIR__ . '/..' . '/../lib/OCM/CloudFederationProviderFiles.php', diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index 2e2f0d8adb..13348a1d7b 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -462,7 +462,7 @@ class FederatedShareProvider implements IShareProvider { * @param $shareId * @param $remoteId */ - public function storeRemoteId($shareId, $remoteId) { + public function storeRemoteId(int $shareId, string $remoteId): void { $query = $this->dbConnection->getQueryBuilder(); $query->insert('federated_reshares') ->values( @@ -478,10 +478,10 @@ class FederatedShareProvider implements IShareProvider { * get share ID on remote server for federated re-shares * * @param IShare $share - * @return int + * @return string * @throws ShareNotFound */ - public function getRemoteId(IShare $share) { + public function getRemoteId(IShare $share): string { $query = $this->dbConnection->getQueryBuilder(); $query->select('remote_id')->from('federated_reshares') ->where($query->expr()->eq('share_id', $query->createNamedParameter((int)$share->getId()))); @@ -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 bf0d0f8eec..afd41c20f6 100644 --- a/apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php +++ b/apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php @@ -44,13 +44,13 @@ class Version1010Date20200630191755 extends SimpleMigrationStep { if (!$schema->hasTable('federated_reshares')) { $table = $schema->createTable('federated_reshares'); - $table->addColumn('share_id', Types::INTEGER, [ + $table->addColumn('share_id', Types::BIGINT, [ 'notnull' => true, - 'length' => 4, ]); - $table->addColumn('remote_id', Types::INTEGER, [ - 'notnull' => true, - 'length' => 4, + $table->addColumn('remote_id', Types::STRING, [ + '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 new file mode 100644 index 0000000000..e89838c06f --- /dev/null +++ b/apps/federatedfilesharing/lib/Migration/Version1011Date20201120125158.php @@ -0,0 +1,71 @@ + + * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +declare(strict_types=1); + +namespace OCA\FederatedFileSharing\Migration; + +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(); + + if ($schema->hasTable('federated_reshares')) { + $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(''); + return $schema; + } + } + + 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 61513cd229..b0add6befb 100644 --- a/apps/federatedfilesharing/lib/Notifications.php +++ b/apps/federatedfilesharing/lib/Notifications.php @@ -83,7 +83,7 @@ class Notifications { * @param string $token * @param string $shareWith * @param string $name - * @param int $remote_id + * @param string $remoteId * @param string $owner * @param string $ownerFederatedId * @param string $sharedBy @@ -93,7 +93,7 @@ class Notifications { * @throws \OC\HintException * @throws \OC\ServerNotAvailableException */ - public function sendRemoteShare($token, $shareWith, $name, $remote_id, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId, $shareType) { + public function sendRemoteShare($token, $shareWith, $name, $remoteId, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId, $shareType) { list($user, $remote) = $this->addressHandler->splitUserRemote($shareWith); if ($user && $remote) { @@ -103,7 +103,7 @@ class Notifications { 'shareWith' => $user, 'token' => $token, 'name' => $name, - 'remoteId' => $remote_id, + 'remoteId' => $remoteId, 'owner' => $owner, 'ownerFederatedId' => $ownerFederatedId, 'sharedBy' => $sharedBy, @@ -132,13 +132,13 @@ class Notifications { * ask owner to re-share the file with the given user * * @param string $token - * @param int $id remote Id - * @param int $shareId internal share Id + * @param string $id remote 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 bool + * @return array|false * @throws \OC\HintException * @throws \OC\ServerNotAvailableException */ @@ -151,7 +151,7 @@ class Notifications { ]; $ocmFields = $fields; - $ocmFields['remoteId'] = $id; + $ocmFields['remoteId'] = (string)$id; $ocmFields['localId'] = $shareId; $ocmFields['name'] = $filename; @@ -171,7 +171,7 @@ class Notifications { if ($httpRequestSuccessful && $ocsCallSuccessful && $validToken && $validRemoteId) { return [ $status['ocs']['data']['token'], - (int)$status['ocs']['data']['remoteId'] + $status['ocs']['data']['remoteId'] ]; } @@ -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 */ @@ -206,7 +206,7 @@ class Notifications { * 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 @@ -219,7 +219,7 @@ class Notifications { * forward accept reShare to remote server * * @param string $remote - * @param int $remoteId + * @param string $remoteId * @param string $token */ public function sendAcceptShare($remote, $remoteId, $token) { @@ -230,7 +230,7 @@ class Notifications { * 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 @@ class Notifications { * * @param string $remote * @param string $token - * @param int $remoteId Share id on the remote host + * @param string $remoteId Share id on the remote host * @param string $action possible actions: accept, decline, unshare, revoke, permissions * @param array $data * @param int $try diff --git a/apps/files_sharing/appinfo/database.xml b/apps/files_sharing/appinfo/database.xml deleted file mode 100644 index c3cfb9e1c8..0000000000 --- a/apps/files_sharing/appinfo/database.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - *dbname* - true - false - utf8 - - *dbprefix*share_external - - - id - integer - 0 - true - 1 - 4 - - - parent - integer - -1 - 4 - - - share_type - integer - 4 - - - remote - text - true - 512 - Url of the remove owncloud instance - - - remote_id - integer - -1 - true - 4 - - - share_token - text - true - 64 - Public share token - - - password - text - false - 64 - Optional password for the public share - - - name - text - true - 64 - Original name on the remote server - - - owner - text - true - 64 - User that owns the public share on the remote server - - - user - text - true - 64 - Local user which added the external share - - - mountpoint - text - true - 4000 - Full path where the share is mounted - - - mountpoint_hash - text - true - 32 - md5 hash of the mountpoint - - - accepted - integer - 0 - true - 4 - - - sh_external_user - - user - ascending - - - - sh_external_mp - true - - user - ascending - - - mountpoint_hash - ascending - - - -
-
diff --git a/apps/files_sharing/appinfo/info.xml b/apps/files_sharing/appinfo/info.xml index e9576dd1ad..492b34859b 100644 --- a/apps/files_sharing/appinfo/info.xml +++ b/apps/files_sharing/appinfo/info.xml @@ -9,7 +9,7 @@ Turning the feature off removes shared files and folders on the server for all share recipients, and also on the sync clients and mobile apps. More information is available in the Nextcloud Documentation. - 1.12.0 + 1.12.1 agpl Michael Gapczynski Bjoern Schiessle diff --git a/apps/files_sharing/composer/composer/autoload_classmap.php b/apps/files_sharing/composer/composer/autoload_classmap.php index 4ba8d1659a..a29e3879e0 100644 --- a/apps/files_sharing/composer/composer/autoload_classmap.php +++ b/apps/files_sharing/composer/composer/autoload_classmap.php @@ -62,6 +62,7 @@ return array( 'OCA\\Files_Sharing\\Migration\\OwncloudGuestShareType' => $baseDir . '/../lib/Migration/OwncloudGuestShareType.php', 'OCA\\Files_Sharing\\Migration\\SetAcceptedStatus' => $baseDir . '/../lib/Migration/SetAcceptedStatus.php', 'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => $baseDir . '/../lib/Migration/SetPasswordColumn.php', + 'OCA\\Files_Sharing\\Migration\\Version11300Date20201120141438' => $baseDir . '/../lib/Migration/Version11300Date20201120141438.php', 'OCA\\Files_Sharing\\MountProvider' => $baseDir . '/../lib/MountProvider.php', 'OCA\\Files_Sharing\\Notification\\Listener' => $baseDir . '/../lib/Notification/Listener.php', 'OCA\\Files_Sharing\\Notification\\Notifier' => $baseDir . '/../lib/Notification/Notifier.php', diff --git a/apps/files_sharing/composer/composer/autoload_static.php b/apps/files_sharing/composer/composer/autoload_static.php index 4376ad0b82..523f2bc194 100644 --- a/apps/files_sharing/composer/composer/autoload_static.php +++ b/apps/files_sharing/composer/composer/autoload_static.php @@ -77,6 +77,7 @@ class ComposerStaticInitFiles_Sharing 'OCA\\Files_Sharing\\Migration\\OwncloudGuestShareType' => __DIR__ . '/..' . '/../lib/Migration/OwncloudGuestShareType.php', 'OCA\\Files_Sharing\\Migration\\SetAcceptedStatus' => __DIR__ . '/..' . '/../lib/Migration/SetAcceptedStatus.php', 'OCA\\Files_Sharing\\Migration\\SetPasswordColumn' => __DIR__ . '/..' . '/../lib/Migration/SetPasswordColumn.php', + 'OCA\\Files_Sharing\\Migration\\Version11300Date20201120141438' => __DIR__ . '/..' . '/../lib/Migration/Version11300Date20201120141438.php', 'OCA\\Files_Sharing\\MountProvider' => __DIR__ . '/..' . '/../lib/MountProvider.php', 'OCA\\Files_Sharing\\Notification\\Listener' => __DIR__ . '/..' . '/../lib/Notification/Listener.php', 'OCA\\Files_Sharing\\Notification\\Notifier' => __DIR__ . '/..' . '/../lib/Notification/Notifier.php', diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index fd71f58f12..078a0a5f59 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -168,7 +168,7 @@ class Application extends App { protected function setupSharingMenus() { $config = \OC::$server->getConfig(); - if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') { + if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes' || !class_exists('\OCA\Files\App')) { return; } diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php index 526e4fcce4..e4b28804fc 100644 --- a/apps/files_sharing/lib/External/Manager.php +++ b/apps/files_sharing/lib/External/Manager.php @@ -126,12 +126,12 @@ class Manager { * @param int $shareType * @param boolean $accepted * @param string $user - * @param int $remoteId + * @param string $remoteId * @param int $parent * @return Mount|null * @throws \Doctrine\DBAL\DBALException */ - public function addShare($remote, $token, $password, $name, $owner, $shareType, $accepted=false, $user = null, $remoteId = -1, $parent = -1) { + public function addShare($remote, $token, $password, $name, $owner, $shareType, $accepted = false, $user = null, $remoteId = '', $parent = -1) { $user = $user ? $user : $this->uid; $accepted = $accepted ? IShare::STATUS_ACCEPTED : IShare::STATUS_PENDING; $name = Filesystem::normalizePath('/' . $name); @@ -347,7 +347,7 @@ class Manager { * * @param string $remote * @param string $token - * @param int $remoteId Share id on the remote host + * @param string $remoteId Share id on the remote host * @param string $feedback * @return boolean */ @@ -388,7 +388,7 @@ class Manager { * * @param string $remoteDomain * @param string $token - * @param $remoteId id of the share + * @param string $remoteId id of the share * @param string $feedback * @return bool */ diff --git a/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php b/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php new file mode 100644 index 0000000000..dfc5bc68a0 --- /dev/null +++ b/apps/files_sharing/lib/Migration/Version11300Date20201120141438.php @@ -0,0 +1,131 @@ + + * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + + +namespace OCA\Files_Sharing\Migration; + +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 Version11300Date20201120141438 extends SimpleMigrationStep { + + /** @var IDBConnection */ + private $connection; + + public function __construct(IDBConnection $connection) { + $this->connection = $connection; + } + + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + if (!$schema->hasTable('share_external')) { + $table = $schema->createTable('share_external'); + $table->addColumn('id', Types::BIGINT, [ + 'autoincrement' => true, + 'notnull' => true, + ]); + $table->addColumn('parent', Types::BIGINT, [ + 'notnull' => false, + 'default' => -1, + ]); + $table->addColumn('share_type', Types::INTEGER, [ + 'notnull' => false, + 'length' => 4, + ]); + $table->addColumn('remote', Types::STRING, [ + 'notnull' => true, + 'length' => 512, + ]); + $table->addColumn('remote_id', Types::STRING, [ + 'notnull' => false, + 'length' => 255, + 'default' => '', + ]); + $table->addColumn('share_token', Types::STRING, [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('password', Types::STRING, [ + 'notnull' => false, + 'length' => 64, + ]); + $table->addColumn('name', Types::STRING, [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('owner', Types::STRING, [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('user', Types::STRING, [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('mountpoint', Types::STRING, [ + 'notnull' => true, + 'length' => 4000, + ]); + $table->addColumn('mountpoint_hash', Types::STRING, [ + 'notnull' => true, + 'length' => 32, + ]); + $table->addColumn('accepted', Types::INTEGER, [ + 'notnull' => true, + 'length' => 4, + 'default' => 0, + ]); + $table->setPrimaryKey(['id']); + $table->addIndex(['user'], 'sh_external_user'); + $table->addUniqueIndex(['user', 'mountpoint_hash'], 'sh_external_mp'); + } else { + $table = $schema->getTable('share_external'); + $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(''); + } + } + + return $schema; + } + + public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) { + $qb = $this->connection->getQueryBuilder(); + $qb->update('share_external') + ->set('remote_id', $qb->createNamedParameter('')) + ->where($qb->expr()->eq('remote_id', $qb->createNamedParameter('-1'))); + $qb->execute(); + } +} diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php index 22005c8fc6..2734e3cce6 100644 --- a/apps/files_sharing/tests/External/ManagerTest.php +++ b/apps/files_sharing/tests/External/ManagerTest.php @@ -149,6 +149,7 @@ class ManagerTest extends TestCase { 'shareType' => IShare::TYPE_USER, 'accepted' => false, 'user' => $this->uid, + 'remote_id' => '2342' ]; $shareData2 = $shareData1; $shareData2['token'] = 'token2'; @@ -158,8 +159,8 @@ class ManagerTest extends TestCase { $this->userManager->expects($this->any())->method('get')->willReturn($this->user); $this->groupManager->expects($this->any())->method(('getUserGroups'))->willReturn([]); - $this->manager->expects($this->at(0))->method('tryOCMEndPoint')->with('http://localhost', 'token1', -1, 'accept')->willReturn(false); - $this->manager->expects($this->at(1))->method('tryOCMEndPoint')->with('http://localhost', 'token3', -1, 'decline')->willReturn(false); + $this->manager->expects($this->at(0))->method('tryOCMEndPoint')->with('http://localhost', 'token1', '2342', 'accept')->willReturn(false); + $this->manager->expects($this->at(1))->method('tryOCMEndPoint')->with('http://localhost', 'token3', '2342', 'decline')->willReturn(false); // Add a share for "user" $this->assertSame(null, call_user_func_array([$this->manager, 'addShare'], $shareData1)); diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 8a0536c29f..19d932ecc4 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -630,12 +630,14 @@ Raw output 'activity_mq' => ['mail_id'], 'authtoken' => ['id'], 'bruteforce_attempts' => ['id'], + 'federated_reshares' => ['share_id'], 'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart', 'mtime', 'storage_mtime'], 'filecache_extended' => ['fileid'], 'file_locks' => ['id'], 'jobs' => ['id'], 'mimetypes' => ['id'], 'mounts' => ['id', 'storage_id', 'root_id', 'mount_id'], + 'share_external' => ['id', 'parent'], 'storages' => ['numeric_id'], ]; diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index d00ea631e5..d6c0ce573a 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -760,7 +760,7 @@ string[] - + null $this->circleToPrincipal($name) null @@ -1211,33 +1211,22 @@ $qb->createNamedParameter($this->supportedShareType, IQueryBuilder::PARAM_INT_ARRAY) $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY) - - $token - $remoteId - - - list($token, $remoteId) - $shares getSharesInFolder - + $shareId $shareId $shareId $shareId - $share->getId() (int)$data['id'] - - [$ocmResult['token'], $ocmResult['providerId']] - - + bool bool bool @@ -1251,8 +1240,7 @@ string - - $remoteId + $id $id $id @@ -3400,9 +3388,6 @@ strtolower - - - $default @@ -4793,14 +4778,6 @@ true - - - $position - - - $cacheEntry - - false @@ -5529,7 +5506,7 @@ 'OCP\Share::postUnshareFromSelf' $data - + $this->shareApiLinkDefaultExpireDays() $this->shareApiLinkDefaultExpireDays() $id diff --git a/core/Command/Db/ConvertFilecacheBigInt.php b/core/Command/Db/ConvertFilecacheBigInt.php index 6b5b0dc9c8..6575d41d3b 100644 --- a/core/Command/Db/ConvertFilecacheBigInt.php +++ b/core/Command/Db/ConvertFilecacheBigInt.php @@ -64,12 +64,14 @@ class ConvertFilecacheBigInt extends Command { 'activity_mq' => ['mail_id'], 'authtoken' => ['id'], 'bruteforce_attempts' => ['id'], + 'federated_reshares' => ['share_id'], 'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart', 'mtime', 'storage_mtime'], 'filecache_extended' => ['fileid'], 'file_locks' => ['id'], 'jobs' => ['id'], 'mimetypes' => ['id'], 'mounts' => ['id', 'storage_id', 'root_id', 'mount_id'], + 'share_external' => ['id', 'parent'], 'storages' => ['numeric_id'], ]; } diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php index b5021dcccf..52b0b0ff03 100644 --- a/tests/lib/DB/MigratorTest.php +++ b/tests/lib/DB/MigratorTest.php @@ -13,6 +13,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\SchemaConfig; +use OC\DB\SchemaWrapper; use OCP\IConfig; /** @@ -94,6 +95,26 @@ class MigratorTest extends \Test\TestCase { return [$startSchema, $endSchema]; } + /** + * @return \Doctrine\DBAL\Schema\Schema[] + */ + private function getChangedTypeSchema($from, $to) { + $startSchema = new Schema([], [], $this->getSchemaConfig()); + $table = $startSchema->createTable($this->tableName); + $table->addColumn('id', $from); + $table->addColumn('name', 'string'); + $table->addIndex(['id'], $this->tableName . '_id'); + + $endSchema = new Schema([], [], $this->getSchemaConfig()); + $table = $endSchema->createTable($this->tableName); + $table->addColumn('id', $to); + $table->addColumn('name', 'string'); + $table->addIndex(['id'], $this->tableName . '_id'); + + return [$startSchema, $endSchema]; + } + + private function getSchemaConfig() { $config = new SchemaConfig(); $config->setName($this->connection->getDatabase()); @@ -123,6 +144,34 @@ class MigratorTest extends \Test\TestCase { $this->fail('checkMigrate should have failed'); } + public function testChangeToString() { + list($startSchema, $endSchema) = $this->getChangedTypeSchema('integer', 'string'); + $migrator = $this->manager->getMigrator(); + $migrator->migrate($startSchema); + $schema = new SchemaWrapper($this->connection); + $table = $schema->getTable(substr($this->tableName, 3)); + $this->assertEquals('integer', $table->getColumn('id')->getType()->getName()); + + $this->connection->insert($this->tableName, ['id' => 1, 'name' => 'foo']); + $this->connection->insert($this->tableName, ['id' => 2, 'name' => 'bar']); + $this->connection->insert($this->tableName, ['id' => 3, 'name' => 'qwerty']); + + $migrator->checkMigrate($endSchema); + $migrator->migrate($endSchema); + $this->addToAssertionCount(1); + + $qb = $this->connection->getQueryBuilder(); + $result = $qb->select('*')->from(substr($this->tableName, 3))->execute(); + $this->assertEquals([ + ['id' => 1, 'name' => 'foo'], + ['id' => 2, 'name' => 'bar'], + ['id' => 3, 'name' => 'qwerty'] + ], $result->fetchAll()); + $schema = new SchemaWrapper($this->connection); + $table = $schema->getTable(substr($this->tableName, 3)); + $this->assertEquals('string', $table->getColumn('id')->getType()->getName()); + } + public function testUpgrade() { list($startSchema, $endSchema) = $this->getDuplicateKeySchemas(); $migrator = $this->manager->getMigrator();