From 712cae756e76616114b5c814e9454a821ce83a1b Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Mon, 17 Feb 2020 09:38:56 -0100 Subject: [PATCH] 0.18.3 Signed-off-by: Maxence Lange --- CHANGELOG.md | 2 +- Makefile | 2 +- appinfo/info.xml | 2 +- lib/Db/MembersRequest.php | 2 +- .../Version0017Date20200202112903.php | 162 ++++++++++-------- .../Version0017Date20200214112607.php | 2 +- 6 files changed, 98 insertions(+), 74 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e65a6ef6b..7ca4c0b13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file. -### 0.18.2 +### 0.18.3 - fixing issue during migration. diff --git a/Makefile b/Makefile index e5dde1049..a09860770 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ package_name=$(app_name) cert_dir=$(HOME)/.nextcloud/certificates github_account=nextcloud branch=master -version+=0.18.2 +version+=0.18.3 all: appstore diff --git a/appinfo/info.xml b/appinfo/info.xml index 27d978536..0edda31b4 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -23,7 +23,7 @@ Users won't be able to find this Circle using Nextcloud search engine. ]]> - 0.18.2 + 0.18.3 agpl Maxence Lange diff --git a/lib/Db/MembersRequest.php b/lib/Db/MembersRequest.php index f45654924..5375ca62c 100644 --- a/lib/Db/MembersRequest.php +++ b/lib/Db/MembersRequest.php @@ -426,7 +426,7 @@ public function forceGetHigherLevelGroupFromUser($circleUniqueId, $userId) { public function createMember(Member $member) { if ($member->getMemberId() === '') { - $member->setMemberId($this->token()); + $member->setMemberId($this->token(14)); } try { diff --git a/lib/Migration/Version0017Date20200202112903.php b/lib/Migration/Version0017Date20200202112903.php index 19a593b59..27cb1bfdb 100644 --- a/lib/Migration/Version0017Date20200202112903.php +++ b/lib/Migration/Version0017Date20200202112903.php @@ -73,81 +73,93 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); - $table = $schema->createTable('circles_members'); - $table->addColumn( - 'circle_id', 'string', [ + if ($schema->hasTable('circles_members')) { + $table = $schema->getTable('circles_members'); + $table->changeColumn( + 'instance', [ + 'default' => '' + ] + ); + } else { + + $table = $schema->createTable('circles_members'); + $table->addColumn( + 'circle_id', 'string', [ + 'notnull' => true, + 'length' => 64, + ] + ); + $table->addColumn( + 'user_id', 'string', [ + 'notnull' => true, + 'length' => 128, + ] + ); + $table->addColumn( + 'instance', 'string', [ + 'notnull' => false, + 'default' => '', + 'length' => 255, + ] + ); + $table->addColumn( + 'user_type', 'smallint', [ + 'notnull' => true, + 'length' => 1, + 'default' => 1, + ] + ); + $table->addColumn( + 'level', 'smallint', [ 'notnull' => true, - 'length' => 64, + 'length' => 1, ] - ); - $table->addColumn( - 'user_id', 'string', [ - 'notnull' => true, - 'length' => 128, - ] - ); - $table->addColumn( - 'instance', 'string', [ + ); + $table->addColumn( + 'status', 'string', [ + 'notnull' => false, + 'length' => 15, + ] + ); + $table->addColumn( + 'note', 'string', [ 'notnull' => false, 'length' => 255, ] - ); - $table->addColumn( - 'user_type', 'smallint', [ - 'notnull' => true, - 'length' => 1, - 'default' => 1, - ] - ); - $table->addColumn( - 'level', 'smallint', [ - 'notnull' => true, - 'length' => 1, - ] - ); - $table->addColumn( - 'status', 'string', [ - 'notnull' => false, - 'length' => 15, - ] - ); - $table->addColumn( - 'note', 'string', [ - 'notnull' => false, - 'length' => 255, - ] - ); - $table->addColumn( - 'joined', 'datetime', [ - 'notnull' => false, - ] - ); - $table->addColumn( - 'member_id', Type::STRING, [ - 'notnull' => false, - 'length' => 15, - ] - ); - $table->addColumn( - 'contact_meta', 'string', [ - 'notnull' => false, - 'length' => 1000, - ] - ); - $table->addColumn( - 'contact_checked', Type::SMALLINT, [ - 'notnull' => false, - 'length' => 1, - ] - ); - $table->addColumn( - 'contact_id', 'string', [ + ); + $table->addColumn( + 'joined', 'datetime', [ 'notnull' => false, - 'length' => 127, ] - ); + ); + $table->addColumn( + 'member_id', Type::STRING, [ + 'notnull' => false, + 'length' => 15, + ] + ); + $table->addColumn( + 'contact_meta', 'string', [ + 'notnull' => false, + 'length' => 1000, + ] + ); + $table->addColumn( + 'contact_checked', Type::SMALLINT, [ + 'notnull' => false, + 'length' => 1, + ] + ); + $table->addColumn( + 'contact_id', 'string', [ + 'notnull' => false, + 'length' => 127, + ] + ); + + $table->setPrimaryKey(['circle_id', 'user_id', 'user_type', 'contact_id', 'instance']); + } - $table->setPrimaryKey(['circle_id', 'user_id', 'user_type', 'contact_id', 'instance']); return $schema; } @@ -158,7 +170,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt * @param array $options */ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { - $this->copyTable('circles_mb_tmp', 'circles_members'); + $this->copyTable('circles_mb_tmp', 'circles_members', ['instance' => '', 'contact_id' => '']); $this->updateMemberId(); $this->updateTokens(); @@ -236,7 +248,12 @@ private function updateTokens() { } - protected function copyTable($orig, $dest) { + /** + * @param $orig + * @param $dest + * @param array $default + */ + protected function copyTable($orig, $dest, array $default = []) { $connection = \OC::$server->getDatabaseConnection(); $qb = $connection->getQueryBuilder(); @@ -254,6 +271,13 @@ protected function copyTable($orig, $dest) { $copy->setValue($k, $copy->createNamedParameter($row[$k])); } } + + $ak = array_keys($default); + foreach($ak as $k) { +// if (!array_key_exists($k, $row)) { + $copy->setValue($k, $copy->createNamedParameter($default[$k])); +// } + } $copy->execute(); } diff --git a/lib/Migration/Version0017Date20200214112607.php b/lib/Migration/Version0017Date20200214112607.php index 3f6667e26..0f05c3ee8 100644 --- a/lib/Migration/Version0017Date20200214112607.php +++ b/lib/Migration/Version0017Date20200214112607.php @@ -69,7 +69,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt $table = $schema->getTable('circles_members'); $table->changeColumn( 'instance', [ - 'default' => '0', + 'default' => '', ] );