From a35b0956f1eb741a1c16d9408048623cb9bc3c02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Tue, 3 Nov 2020 17:24:06 +0100 Subject: [PATCH 01/19] Add github action for oci8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .github/workflows/oci.yml | 53 +++++++++++++++++++++++++++++++++++++ tests/lib/AppConfigTest.php | 5 ++-- tests/lib/DB/testschema.xml | 2 +- 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/oci.yml diff --git a/.github/workflows/oci.yml b/.github/workflows/oci.yml new file mode 100644 index 00000000000..87cc1d41d44 --- /dev/null +++ b/.github/workflows/oci.yml @@ -0,0 +1,53 @@ +name: "Unit tests" + +on: + push: + +jobs: + phpunit-oci8: + name: "PHPUnit on OCI8" + runs-on: "ubuntu-latest" + + strategy: + matrix: + php-version: + - "7.4" + + services: + oracle: + image: deepdiver/docker-oracle-xe-11g # "wnameless/oracle-xe-11g-r2" + ports: + - "1521:1521" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: Checkout submodules + shell: bash + run: | + auth_header="$(git config --local --get http.https://github.com/.extraheader)" + git submodule sync --recursive + git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite, oci8 + tools: phpunit:8.5.2 + coverage: none + + - name: Set up Nextcloud + run: | + mkdir data + ./occ maintenance:install --verbose --database=oci --database-name=XE --database-host=127.0.0.1 --database-port=1521 --database-user=autotest --database-pass=owncloud --admin-user admin --admin-pass admin + + # Generate instance id by loading index.php + - name: Generate instance id by loading index.php + run: | + php -f index.php + + - name: Run phpunit + run: | + cd tests && phpunit --configuration phpunit-autotest.xml --group DB,SLOWDB diff --git a/tests/lib/AppConfigTest.php b/tests/lib/AppConfigTest.php index ff23454eb8b..40a99709bd5 100644 --- a/tests/lib/AppConfigTest.php +++ b/tests/lib/AppConfigTest.php @@ -9,6 +9,7 @@ namespace Test; +use OC\AppConfig; use OCP\IConfig; /** @@ -42,7 +43,7 @@ class AppConfigTest extends TestCase { $sql->delete('appconfig'); $sql->execute(); - $this->overwriteService('AppConfig', new \OC\AppConfig($this->connection)); + $this->overwriteService(AppConfig::class, new \OC\AppConfig($this->connection)); $sql = $this->connection->getQueryBuilder(); $sql->insert('appconfig') @@ -132,7 +133,7 @@ class AppConfigTest extends TestCase { $sql->execute(); } - $this->restoreService('AppConfig'); + $this->restoreService(AppConfig::class); parent::tearDown(); } diff --git a/tests/lib/DB/testschema.xml b/tests/lib/DB/testschema.xml index 5f449c936d9..d42dbe8d581 100644 --- a/tests/lib/DB/testschema.xml +++ b/tests/lib/DB/testschema.xml @@ -37,7 +37,7 @@ clobfield - clob + text booleanfield From f58ffadb347c5ab1baed016f922d3b382e2e5173 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 4 Nov 2020 16:02:58 +0100 Subject: [PATCH 02/19] Use a different column for the primary key as we can not insert it on oracle Signed-off-by: Joas Schilling --- tests/lib/DB/MDB2SchemaReaderTest.php | 30 +++++++++++++++++---------- tests/lib/DB/testschema.xml | 18 +++++++++++++++- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/tests/lib/DB/MDB2SchemaReaderTest.php b/tests/lib/DB/MDB2SchemaReaderTest.php index c57b0f22b6f..b3dd98fd6b7 100644 --- a/tests/lib/DB/MDB2SchemaReaderTest.php +++ b/tests/lib/DB/MDB2SchemaReaderTest.php @@ -14,6 +14,10 @@ use Doctrine\DBAL\Schema\Schema; use OC\DB\MDB2SchemaReader; use OCP\IConfig; use Test\TestCase; +use Doctrine\DBAL\Types\IntegerType; +use Doctrine\DBAL\Types\TextType; +use Doctrine\DBAL\Types\StringType; +use Doctrine\DBAL\Types\BooleanType; /** * Class MDB2SchemaReaderTest @@ -51,13 +55,13 @@ class MDB2SchemaReaderTest extends TestCase { $this->assertCount(1, $schema->getTables()); $table = $schema->getTable('test_table'); - $this->assertCount(8, $table->getColumns()); + $this->assertCount(9, $table->getColumns()); - $this->assertEquals(4, $table->getColumn('integerfield')->getLength()); - $this->assertTrue($table->getColumn('integerfield')->getAutoincrement()); - $this->assertEquals(0, $table->getColumn('integerfield')->getDefault()); - $this->assertTrue($table->getColumn('integerfield')->getNotnull()); - $this->assertInstanceOf('Doctrine\DBAL\Types\IntegerType', $table->getColumn('integerfield')->getType()); + $this->assertEquals(4, $table->getColumn('id')->getLength()); + $this->assertTrue($table->getColumn('id')->getAutoincrement()); + $this->assertEquals(0, $table->getColumn('id')->getDefault()); + $this->assertTrue($table->getColumn('id')->getNotnull()); + $this->assertInstanceOf(IntegerType::class, $table->getColumn('id')->getType()); $this->assertSame(10, $table->getColumn('integerfield_default')->getDefault()); @@ -65,18 +69,19 @@ class MDB2SchemaReaderTest extends TestCase { $this->assertFalse($table->getColumn('textfield')->getAutoincrement()); $this->assertSame('foo', $table->getColumn('textfield')->getDefault()); $this->assertTrue($table->getColumn('textfield')->getNotnull()); - $this->assertInstanceOf('Doctrine\DBAL\Types\StringType', $table->getColumn('textfield')->getType()); + $this->assertInstanceOf(StringType::class, $table->getColumn('textfield')->getType()); $this->assertNull($table->getColumn('clobfield')->getLength()); $this->assertFalse($table->getColumn('clobfield')->getAutoincrement()); $this->assertNull($table->getColumn('clobfield')->getDefault()); $this->assertFalse($table->getColumn('clobfield')->getNotnull()); - $this->assertInstanceOf('Doctrine\DBAL\Types\TextType', $table->getColumn('clobfield')->getType()); + $this->assertInstanceOf(StringType::class, $table->getColumn('clobfield')->getType()); +// $this->assertInstanceOf(TextType::class, $table->getColumn('clobfield')->getType()); $this->assertNull($table->getColumn('booleanfield')->getLength()); $this->assertFalse($table->getColumn('booleanfield')->getAutoincrement()); $this->assertNull($table->getColumn('booleanfield')->getDefault()); - $this->assertInstanceOf('Doctrine\DBAL\Types\BooleanType', $table->getColumn('booleanfield')->getType()); + $this->assertInstanceOf(BooleanType::class, $table->getColumn('booleanfield')->getType()); $this->assertTrue($table->getColumn('booleanfield_true')->getDefault()); $this->assertFalse($table->getColumn('booleanfield_false')->getDefault()); @@ -84,10 +89,13 @@ class MDB2SchemaReaderTest extends TestCase { $this->assertEquals(12, $table->getColumn('decimalfield_precision_scale')->getPrecision()); $this->assertEquals(2, $table->getColumn('decimalfield_precision_scale')->getScale()); - $this->assertCount(2, $table->getIndexes()); - $this->assertEquals(['integerfield'], $table->getIndex('primary')->getUnquotedColumns()); + $this->assertCount(3, $table->getIndexes()); + $this->assertEquals(['id'], $table->getIndex('primary')->getUnquotedColumns()); $this->assertTrue($table->getIndex('primary')->isPrimary()); $this->assertTrue($table->getIndex('primary')->isUnique()); + $this->assertEquals(['integerfield'], $table->getIndex('index_integerfield')->getUnquotedColumns()); + $this->assertFalse($table->getIndex('index_integerfield')->isPrimary()); + $this->assertTrue($table->getIndex('index_integerfield')->isUnique()); $this->assertEquals(['booleanfield'], $table->getIndex('index_boolean')->getUnquotedColumns()); $this->assertFalse($table->getIndex('index_boolean')->isPrimary()); $this->assertFalse($table->getIndex('index_boolean')->isUnique()); diff --git a/tests/lib/DB/testschema.xml b/tests/lib/DB/testschema.xml index d42dbe8d581..a2b01d8259e 100644 --- a/tests/lib/DB/testschema.xml +++ b/tests/lib/DB/testschema.xml @@ -13,7 +13,7 @@ - integerfield + id integer 0 true @@ -21,6 +21,13 @@ 4 1 + + integerfield + integer + 0 + true + 4 + integerfield_default integer @@ -64,6 +71,15 @@ index_primary true true + + id + ascending + + + + + index_integerfield + true integerfield ascending From 3ec48cd59fb67372917849555fe5679de3c68a9c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 4 Nov 2020 16:03:45 +0100 Subject: [PATCH 03/19] Easier debugging and spell fix Signed-off-by: Joas Schilling --- tests/lib/DB/ConnectionTest.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/lib/DB/ConnectionTest.php b/tests/lib/DB/ConnectionTest.php index be84cb81cb3..5a2823ef28e 100644 --- a/tests/lib/DB/ConnectionTest.php +++ b/tests/lib/DB/ConnectionTest.php @@ -97,14 +97,17 @@ class ConnectionTest extends \Test\TestCase { $this->assertTableNotExist('table'); } - private function getTextValueByIntergerField($integerField) { + private function getTextValueByIntegerField($integerField) { $builder = $this->connection->getQueryBuilder(); - $query = $builder->select('textfield') + $query = $builder->select('*') ->from('table') ->where($builder->expr()->eq('integerfield', $builder->createNamedParameter($integerField, IQueryBuilder::PARAM_INT))); $result = $query->execute(); - return $result->fetchColumn(); + $row = $result->fetch(); + $result->closeCursor(); + + return $row['textfield'] ?? null; } public function testSetValues() { @@ -116,7 +119,7 @@ class ConnectionTest extends \Test\TestCase { 'clobfield' => 'not_null' ]); - $this->assertEquals('foo', $this->getTextValueByIntergerField(1)); + $this->assertEquals('foo', $this->getTextValueByIntegerField(1)); } public function testSetValuesOverWrite() { @@ -133,7 +136,7 @@ class ConnectionTest extends \Test\TestCase { 'textfield' => 'bar' ]); - $this->assertEquals('bar', $this->getTextValueByIntergerField(1)); + $this->assertEquals('bar', $this->getTextValueByIntegerField(1)); } public function testSetValuesOverWritePrecondition() { @@ -154,7 +157,7 @@ class ConnectionTest extends \Test\TestCase { 'booleanfield' => true ]); - $this->assertEquals('bar', $this->getTextValueByIntergerField(1)); + $this->assertEquals('bar', $this->getTextValueByIntegerField(1)); } From e3b3ff6d4307cb5fe44d0a8882d58fbb9511541d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 4 Nov 2020 16:40:31 +0100 Subject: [PATCH 04/19] Skip the insertIfNotExists() tests on Oracle because it doesn't work with clob Signed-off-by: Joas Schilling --- tests/lib/DB/ConnectionTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/lib/DB/ConnectionTest.php b/tests/lib/DB/ConnectionTest.php index 5a2823ef28e..fa4d5fe005c 100644 --- a/tests/lib/DB/ConnectionTest.php +++ b/tests/lib/DB/ConnectionTest.php @@ -203,6 +203,10 @@ class ConnectionTest extends \Test\TestCase { } public function testInsertIfNotExist() { + if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') === 'oci') { + self::markTestSkipped('Insert if not exist does not work with clob on oracle'); + } + $this->makeTestTable(); $categoryEntries = [ ['user' => 'test', 'category' => 'Family', 'expectedResult' => 1], @@ -232,6 +236,10 @@ class ConnectionTest extends \Test\TestCase { } public function testInsertIfNotExistNull() { + if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') === 'oci') { + self::markTestSkipped('Insert if not exist does not work with clob on oracle'); + } + $this->makeTestTable(); $categoryEntries = [ ['addressbookid' => 123, 'fullname' => null, 'expectedResult' => 1], @@ -255,6 +263,10 @@ class ConnectionTest extends \Test\TestCase { } public function testInsertIfNotExistDonTOverwrite() { + if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') === 'oci') { + self::markTestSkipped('Insert if not exist does not work with clob on oracle'); + } + $this->makeTestTable(); $fullName = 'fullname test'; $uri = 'uri_1'; @@ -291,6 +303,10 @@ class ConnectionTest extends \Test\TestCase { } public function testInsertIfNotExistsViolating() { + if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') === 'oci') { + self::markTestSkipped('Insert if not exist does not work with clob on oracle'); + } + $this->makeTestTable(); $result = $this->connection->insertIfNotExist('*PREFIX*table', [ @@ -321,6 +337,10 @@ class ConnectionTest extends \Test\TestCase { * @param array $compareKeys */ public function testInsertIfNotExistsViolatingUnique($compareKeys) { + if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') === 'oci') { + self::markTestSkipped('Insert if not exist does not work with clob on oracle'); + } + $this->makeTestTable(); $result = $this->connection->insertIfNotExist('*PREFIX*table', [ From 48c2f6d5a0b384cf81e254baabc19d61aae496e4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 6 Nov 2020 14:12:40 +0100 Subject: [PATCH 05/19] Make the test pass on repeating calls Signed-off-by: Joas Schilling --- apps/oauth2/tests/Db/ClientMapperTest.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/oauth2/tests/Db/ClientMapperTest.php b/apps/oauth2/tests/Db/ClientMapperTest.php index ad1612da6b4..e4a71fc1040 100644 --- a/apps/oauth2/tests/Db/ClientMapperTest.php +++ b/apps/oauth2/tests/Db/ClientMapperTest.php @@ -40,6 +40,13 @@ class ClientMapperTest extends TestCase { $this->clientMapper = new ClientMapper(\OC::$server->getDatabaseConnection()); } + protected function tearDown(): void { + $query = \OC::$server->getDatabaseConnection()->getQueryBuilder(); + $query->delete('oauth2_clients')->execute(); + + parent::tearDown(); + } + public function testGetByIdentifier() { $client = new Client(); $client->setClientIdentifier('MyAwesomeClientIdentifier'); @@ -51,7 +58,6 @@ class ClientMapperTest extends TestCase { $this->assertEquals($client, $this->clientMapper->getByIdentifier('MyAwesomeClientIdentifier')); } - public function testGetByIdentifierNotExisting() { $this->expectException(\OCA\OAuth2\Exceptions\ClientNotFoundException::class); @@ -69,7 +75,6 @@ class ClientMapperTest extends TestCase { $this->assertEquals($client, $this->clientMapper->getByUid($client->getId())); } - public function testGetByUidNotExisting() { $this->expectException(\OCA\OAuth2\Exceptions\ClientNotFoundException::class); From fcef3c0e8a03021591162fb16be84c024c689111 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 6 Nov 2020 14:13:11 +0100 Subject: [PATCH 06/19] Fix "Invalid fetch style: 12" on Oracle Signed-off-by: Joas Schilling --- apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php index 2633ccf544f..86a88b3ccdc 100644 --- a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php +++ b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php @@ -110,10 +110,13 @@ class CustomPropertiesBackendTest extends TestCase { ->where($query->expr()->eq('userid', $query->createNamedParameter($user))) ->where($query->expr()->eq('propertypath', $query->createNamedParameter($this->formatPath($path)))); - $result = $query->execute(); - $data = $result->fetchAll(\PDO::FETCH_KEY_PAIR); + $data = []; + while ($row = $result->fetch()) { + $data[$row['propertyname']] = $row['propertyvalue']; + } $result->closeCursor(); + return $data; } From 8ff0523c3d5a657da90a980ba4f96fc72321104a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 9 Nov 2020 10:38:47 +0100 Subject: [PATCH 07/19] Make sure columns with an empty default are nullable for Oracle Signed-off-by: Joas Schilling --- .../composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- apps/dav/appinfo/info.xml | 2 +- apps/dav/composer/composer/ClassLoader.php | 2 +- .../composer/composer/autoload_classmap.php | 1 + .../dav/composer/composer/autoload_static.php | 1 + .../Version1012Date20190808122342.php | 2 +- .../Version1016Date20201109085907.php | 60 +++++++++++++++++ .../composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- apps/files/composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- apps/oauth2/composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- .../testing/composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- .../composer/composer/ClassLoader.php | 2 +- .../Version13000Date20170718121200.php | 2 +- .../Version14000Date20180710092004.php | 1 + .../Version15000Date20180926101451.php | 4 +- .../Version15000Date20181015062942.php | 2 +- .../Version16000Date20190207141427.php | 2 +- .../Version16000Date20190428150708.php | 2 +- .../Version20000Date20201109081915.php | 64 +++++++++++++++++++ lib/composer/composer/ClassLoader.php | 2 +- lib/composer/composer/autoload_classmap.php | 1 + lib/composer/composer/autoload_static.php | 1 + version.php | 2 +- 41 files changed, 164 insertions(+), 35 deletions(-) create mode 100644 apps/dav/lib/Migration/Version1016Date20201109085907.php create mode 100644 core/Migrations/Version20000Date20201109081915.php diff --git a/apps/accessibility/composer/composer/ClassLoader.php b/apps/accessibility/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/accessibility/composer/composer/ClassLoader.php +++ b/apps/accessibility/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/admin_audit/composer/composer/ClassLoader.php b/apps/admin_audit/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/admin_audit/composer/composer/ClassLoader.php +++ b/apps/admin_audit/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/cloud_federation_api/composer/composer/ClassLoader.php b/apps/cloud_federation_api/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/cloud_federation_api/composer/composer/ClassLoader.php +++ b/apps/cloud_federation_api/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/comments/composer/composer/ClassLoader.php b/apps/comments/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/comments/composer/composer/ClassLoader.php +++ b/apps/comments/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/contactsinteraction/composer/composer/ClassLoader.php b/apps/contactsinteraction/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/contactsinteraction/composer/composer/ClassLoader.php +++ b/apps/contactsinteraction/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/dav/appinfo/info.xml b/apps/dav/appinfo/info.xml index 9eab8e32708..b0bcc782d99 100644 --- a/apps/dav/appinfo/info.xml +++ b/apps/dav/appinfo/info.xml @@ -5,7 +5,7 @@ WebDAV WebDAV endpoint WebDAV endpoint - 1.16.0 + 1.16.1 agpl owncloud.org DAV diff --git a/apps/dav/composer/composer/ClassLoader.php b/apps/dav/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/dav/composer/composer/ClassLoader.php +++ b/apps/dav/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/dav/composer/composer/autoload_classmap.php b/apps/dav/composer/composer/autoload_classmap.php index aaa5e82da04..e0684f0c793 100644 --- a/apps/dav/composer/composer/autoload_classmap.php +++ b/apps/dav/composer/composer/autoload_classmap.php @@ -230,6 +230,7 @@ return array( 'OCA\\DAV\\Migration\\Version1011Date20190725113607' => $baseDir . '/../lib/Migration/Version1011Date20190725113607.php', 'OCA\\DAV\\Migration\\Version1011Date20190806104428' => $baseDir . '/../lib/Migration/Version1011Date20190806104428.php', 'OCA\\DAV\\Migration\\Version1012Date20190808122342' => $baseDir . '/../lib/Migration/Version1012Date20190808122342.php', + 'OCA\\DAV\\Migration\\Version1016Date20201109085907' => $baseDir . '/../lib/Migration/Version1016Date20201109085907.php', 'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningNode' => $baseDir . '/../lib/Provisioning/Apple/AppleProvisioningNode.php', 'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningPlugin' => $baseDir . '/../lib/Provisioning/Apple/AppleProvisioningPlugin.php', 'OCA\\DAV\\RootCollection' => $baseDir . '/../lib/RootCollection.php', diff --git a/apps/dav/composer/composer/autoload_static.php b/apps/dav/composer/composer/autoload_static.php index 0dc34f5a317..32b5e03a3fa 100644 --- a/apps/dav/composer/composer/autoload_static.php +++ b/apps/dav/composer/composer/autoload_static.php @@ -245,6 +245,7 @@ class ComposerStaticInitDAV 'OCA\\DAV\\Migration\\Version1011Date20190725113607' => __DIR__ . '/..' . '/../lib/Migration/Version1011Date20190725113607.php', 'OCA\\DAV\\Migration\\Version1011Date20190806104428' => __DIR__ . '/..' . '/../lib/Migration/Version1011Date20190806104428.php', 'OCA\\DAV\\Migration\\Version1012Date20190808122342' => __DIR__ . '/..' . '/../lib/Migration/Version1012Date20190808122342.php', + 'OCA\\DAV\\Migration\\Version1016Date20201109085907' => __DIR__ . '/..' . '/../lib/Migration/Version1016Date20201109085907.php', 'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningNode' => __DIR__ . '/..' . '/../lib/Provisioning/Apple/AppleProvisioningNode.php', 'OCA\\DAV\\Provisioning\\Apple\\AppleProvisioningPlugin' => __DIR__ . '/..' . '/../lib/Provisioning/Apple/AppleProvisioningPlugin.php', 'OCA\\DAV\\RootCollection' => __DIR__ . '/..' . '/../lib/RootCollection.php', diff --git a/apps/dav/lib/Migration/Version1012Date20190808122342.php b/apps/dav/lib/Migration/Version1012Date20190808122342.php index 7aa51a224ec..51929d1a2f5 100644 --- a/apps/dav/lib/Migration/Version1012Date20190808122342.php +++ b/apps/dav/lib/Migration/Version1012Date20190808122342.php @@ -69,7 +69,7 @@ class Version1012Date20190808122342 extends SimpleMigrationStep { 'length' => 11, ]); $table->addColumn('is_recurring', Types::SMALLINT, [ - 'notnull' => true, + 'notnull' => false, 'length' => 1, ]); $table->addColumn('uid', Types::STRING, [ diff --git a/apps/dav/lib/Migration/Version1016Date20201109085907.php b/apps/dav/lib/Migration/Version1016Date20201109085907.php new file mode 100644 index 00000000000..a43c8ae06a3 --- /dev/null +++ b/apps/dav/lib/Migration/Version1016Date20201109085907.php @@ -0,0 +1,60 @@ + + * + * @author Joas Schilling + * + * @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\DAV\Migration; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +class Version1016Date20201109085907 extends SimpleMigrationStep { + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + $result = $this->ensureColumnIsNullable($schema, 'calendar_reminders', 'is_recurring'); + + return $result ? $schema : null; + } + + protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool { + $table = $schema->getTable($tableName); + $column = $table->getColumn($columnName); + + if ($column->getNotnull()) { + $column->setNotnull(false); + return true; + } + + return false; + } +} diff --git a/apps/encryption/composer/composer/ClassLoader.php b/apps/encryption/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/encryption/composer/composer/ClassLoader.php +++ b/apps/encryption/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/federatedfilesharing/composer/composer/ClassLoader.php b/apps/federatedfilesharing/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/federatedfilesharing/composer/composer/ClassLoader.php +++ b/apps/federatedfilesharing/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/federation/composer/composer/ClassLoader.php b/apps/federation/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/federation/composer/composer/ClassLoader.php +++ b/apps/federation/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/files/composer/composer/ClassLoader.php b/apps/files/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/files/composer/composer/ClassLoader.php +++ b/apps/files/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/files_sharing/composer/composer/ClassLoader.php b/apps/files_sharing/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/files_sharing/composer/composer/ClassLoader.php +++ b/apps/files_sharing/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/files_trashbin/composer/composer/ClassLoader.php b/apps/files_trashbin/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/files_trashbin/composer/composer/ClassLoader.php +++ b/apps/files_trashbin/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/files_versions/composer/composer/ClassLoader.php b/apps/files_versions/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/files_versions/composer/composer/ClassLoader.php +++ b/apps/files_versions/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/lookup_server_connector/composer/composer/ClassLoader.php b/apps/lookup_server_connector/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/lookup_server_connector/composer/composer/ClassLoader.php +++ b/apps/lookup_server_connector/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/oauth2/composer/composer/ClassLoader.php b/apps/oauth2/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/oauth2/composer/composer/ClassLoader.php +++ b/apps/oauth2/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/provisioning_api/composer/composer/ClassLoader.php b/apps/provisioning_api/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/provisioning_api/composer/composer/ClassLoader.php +++ b/apps/provisioning_api/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/settings/composer/composer/ClassLoader.php b/apps/settings/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/settings/composer/composer/ClassLoader.php +++ b/apps/settings/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/sharebymail/composer/composer/ClassLoader.php b/apps/sharebymail/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/sharebymail/composer/composer/ClassLoader.php +++ b/apps/sharebymail/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/systemtags/composer/composer/ClassLoader.php b/apps/systemtags/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/systemtags/composer/composer/ClassLoader.php +++ b/apps/systemtags/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/testing/composer/composer/ClassLoader.php b/apps/testing/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/testing/composer/composer/ClassLoader.php +++ b/apps/testing/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/twofactor_backupcodes/composer/composer/ClassLoader.php b/apps/twofactor_backupcodes/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/twofactor_backupcodes/composer/composer/ClassLoader.php +++ b/apps/twofactor_backupcodes/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/updatenotification/composer/composer/ClassLoader.php b/apps/updatenotification/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/updatenotification/composer/composer/ClassLoader.php +++ b/apps/updatenotification/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/user_ldap/composer/composer/ClassLoader.php b/apps/user_ldap/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/user_ldap/composer/composer/ClassLoader.php +++ b/apps/user_ldap/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/user_status/composer/composer/ClassLoader.php b/apps/user_status/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/user_status/composer/composer/ClassLoader.php +++ b/apps/user_status/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/apps/workflowengine/composer/composer/ClassLoader.php b/apps/workflowengine/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/apps/workflowengine/composer/composer/ClassLoader.php +++ b/apps/workflowengine/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/core/Migrations/Version13000Date20170718121200.php b/core/Migrations/Version13000Date20170718121200.php index f3129c22ca2..fcea6657b30 100644 --- a/core/Migrations/Version13000Date20170718121200.php +++ b/core/Migrations/Version13000Date20170718121200.php @@ -813,7 +813,7 @@ class Version13000Date20170718121200 extends SimpleMigrationStep { if (!$schema->hasTable('credentials')) { $table = $schema->createTable('credentials'); $table->addColumn('user', 'string', [ - 'notnull' => true, + 'notnull' => false, 'length' => 64, ]); $table->addColumn('identifier', 'string', [ diff --git a/core/Migrations/Version14000Date20180710092004.php b/core/Migrations/Version14000Date20180710092004.php index 141b0c1afb5..767d8ee5f7d 100644 --- a/core/Migrations/Version14000Date20180710092004.php +++ b/core/Migrations/Version14000Date20180710092004.php @@ -43,6 +43,7 @@ class Version14000Date20180710092004 extends SimpleMigrationStep { if (!$table->hasColumn('password_by_talk')) { $table->addColumn('password_by_talk', Types::BOOLEAN, [ 'default' => 0, + 'notnull' => false, ]); } diff --git a/core/Migrations/Version15000Date20180926101451.php b/core/Migrations/Version15000Date20180926101451.php index a5f37cc9125..e03a11318c0 100644 --- a/core/Migrations/Version15000Date20180926101451.php +++ b/core/Migrations/Version15000Date20180926101451.php @@ -45,8 +45,8 @@ class Version15000Date20180926101451 extends SimpleMigrationStep { $table = $schema->getTable('authtoken'); $table->addColumn('password_invalid','boolean', [ - 'notnull' => true, - 'default' => false, + 'default' => 0, + 'notnull' => false, ]); return $schema; diff --git a/core/Migrations/Version15000Date20181015062942.php b/core/Migrations/Version15000Date20181015062942.php index eaeaf0dd268..23c2a904741 100644 --- a/core/Migrations/Version15000Date20181015062942.php +++ b/core/Migrations/Version15000Date20181015062942.php @@ -45,7 +45,7 @@ class Version15000Date20181015062942 extends SimpleMigrationStep { $table = $schema->getTable('share'); $table->addColumn('hide_download', 'smallint', [ - 'notnull' => true, + 'notnull' => false, 'length' => 1, 'default' => 0, ]); diff --git a/core/Migrations/Version16000Date20190207141427.php b/core/Migrations/Version16000Date20190207141427.php index e6235efe201..63c6c871eae 100644 --- a/core/Migrations/Version16000Date20190207141427.php +++ b/core/Migrations/Version16000Date20190207141427.php @@ -102,7 +102,7 @@ class Version16000Date20190207141427 extends SimpleMigrationStep { 'default' => '', ]); $table->addColumn('access', Types::SMALLINT, [ - 'notnull' => true, + 'notnull' => false, 'default' => 0, ]); diff --git a/core/Migrations/Version16000Date20190428150708.php b/core/Migrations/Version16000Date20190428150708.php index 546d4c19e14..dc33b08035a 100644 --- a/core/Migrations/Version16000Date20190428150708.php +++ b/core/Migrations/Version16000Date20190428150708.php @@ -49,7 +49,7 @@ class Version16000Date20190428150708 extends SimpleMigrationStep { if ($schema->hasTable('collres_accesscache')) { $table = $schema->getTable('collres_accesscache'); $table->addColumn('access', Types::BOOLEAN, [ - 'notnull' => true, + 'notnull' => false, 'default' => false ]); } diff --git a/core/Migrations/Version20000Date20201109081915.php b/core/Migrations/Version20000Date20201109081915.php new file mode 100644 index 00000000000..720f54d8e8b --- /dev/null +++ b/core/Migrations/Version20000Date20201109081915.php @@ -0,0 +1,64 @@ + + * + * @author Joas Schilling + * + * @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 OC\Core\Migrations; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +class Version20000Date20201109081915 extends SimpleMigrationStep { + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + $result = $this->ensureColumnIsNullable($schema, 'share', 'password_by_talk'); + $result = $this->ensureColumnIsNullable($schema, 'share', 'hide_download') || $result; + $result = $this->ensureColumnIsNullable($schema, 'credentials', 'user') || $result; + $result = $this->ensureColumnIsNullable($schema, 'authtoken', 'password_invalid') || $result; + $result = $this->ensureColumnIsNullable($schema, 'collres_accesscache', 'access') || $result; + + return $result ? $schema : null; + } + + protected function ensureColumnIsNullable(ISchemaWrapper $schema, string $tableName, string $columnName): bool { + $table = $schema->getTable($tableName); + $column = $table->getColumn($columnName); + + if ($column->getNotnull()) { + $column->setNotnull(false); + return true; + } + + return false; + } +} diff --git a/lib/composer/composer/ClassLoader.php b/lib/composer/composer/ClassLoader.php index fce8549f078..03b9bb9c40c 100644 --- a/lib/composer/composer/ClassLoader.php +++ b/lib/composer/composer/ClassLoader.php @@ -60,7 +60,7 @@ class ClassLoader public function getPrefixes() { if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); } return array(); diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index f28e7977a03..48f9f60999d 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -919,6 +919,7 @@ return array( 'OC\\Core\\Migrations\\Version18000Date20191014105105' => $baseDir . '/core/Migrations/Version18000Date20191014105105.php', 'OC\\Core\\Migrations\\Version18000Date20191204114856' => $baseDir . '/core/Migrations/Version18000Date20191204114856.php', 'OC\\Core\\Migrations\\Version19000Date20200211083441' => $baseDir . '/core/Migrations/Version19000Date20200211083441.php', + 'OC\\Core\\Migrations\\Version20000Date20201109081915' => $baseDir . '/core/Migrations/Version20000Date20201109081915.php', 'OC\\Core\\Notification\\RemoveLinkSharesNotifier' => $baseDir . '/core/Notification/RemoveLinkSharesNotifier.php', 'OC\\Core\\Service\\LoginFlowV2Service' => $baseDir . '/core/Service/LoginFlowV2Service.php', 'OC\\DB\\Adapter' => $baseDir . '/lib/private/DB/Adapter.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index e584c63c644..c6f23f18523 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -948,6 +948,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Core\\Migrations\\Version18000Date20191014105105' => __DIR__ . '/../../..' . '/core/Migrations/Version18000Date20191014105105.php', 'OC\\Core\\Migrations\\Version18000Date20191204114856' => __DIR__ . '/../../..' . '/core/Migrations/Version18000Date20191204114856.php', 'OC\\Core\\Migrations\\Version19000Date20200211083441' => __DIR__ . '/../../..' . '/core/Migrations/Version19000Date20200211083441.php', + 'OC\\Core\\Migrations\\Version20000Date20201109081915' => __DIR__ . '/../../..' . '/core/Migrations/Version20000Date20201109081915.php', 'OC\\Core\\Notification\\RemoveLinkSharesNotifier' => __DIR__ . '/../../..' . '/core/Notification/RemoveLinkSharesNotifier.php', 'OC\\Core\\Service\\LoginFlowV2Service' => __DIR__ . '/../../..' . '/core/Service/LoginFlowV2Service.php', 'OC\\DB\\Adapter' => __DIR__ . '/../../..' . '/lib/private/DB/Adapter.php', diff --git a/version.php b/version.php index 9b82df9ca08..f971a54fa15 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ // between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel // when updating major/minor version number. -$OC_Version = [20, 0, 1, 1]; +$OC_Version = [20, 0, 1, 4]; // The human readable string $OC_VersionString = '20.0.1'; From b6ce689e259873c1e294d10b47b3b4a6fd1d5c9c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 9 Nov 2020 10:40:55 +0100 Subject: [PATCH 08/19] Fix public calendars as they are stored with null on oracle Signed-off-by: Joas Schilling --- apps/dav/lib/CalDAV/CalDavBackend.php | 46 ++++++++++++++++++++------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 3115ceea478..a55c8987be3 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -241,8 +241,13 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $principalUri = $this->convertPrincipal($principalUri, true); $query = $this->db->getQueryBuilder(); $query->select($query->func()->count('*')) - ->from('calendars') - ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))); + ->from('calendars'); + + if ($principalUri === '') { + $query->where($query->expr()->emptyString('principaluri')); + } else { + $query->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))); + } if ($excludeBirthday) { $query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI))); @@ -292,13 +297,21 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription // Making fields a comma-delimited list $query = $this->db->getQueryBuilder(); - $query->select($fields)->from('calendars') - ->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))) - ->orderBy('calendarorder', 'ASC'); - $stmt = $query->execute(); + $query->select($fields) + ->from('calendars') + ->orderBy('calendarorder', 'ASC'); + + if ($principalUri === '') { + $query->where($query->expr()->emptyString('principaluri')); + } else { + $query->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri))); + } + + $result = $query->execute(); $calendars = []; - while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + while ($row = $result->fetch()) { + $row['principaluri'] = (string) $row['principaluri']; $components = []; if ($row['components']) { $components = explode(',',$row['components']); @@ -325,8 +338,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $calendars[$calendar['id']] = $calendar; } } - - $stmt->closeCursor(); + $result->closeCursor(); // query for shared calendars $principals = $this->principalBackend->getGroupMembership($principalUriOriginal, true); @@ -346,17 +358,19 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $fields[] = 'a.transparent'; $fields[] = 's.access'; $query = $this->db->getQueryBuilder(); - $result = $query->select($fields) + $query->select($fields) ->from('dav_shares', 's') ->join('s', 'calendars', 'a', $query->expr()->eq('s.resourceid', 'a.id')) ->where($query->expr()->in('s.principaluri', $query->createParameter('principaluri'))) ->andWhere($query->expr()->eq('s.type', $query->createParameter('type'))) ->setParameter('type', 'calendar') - ->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY) - ->execute(); + ->setParameter('principaluri', $principals, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY); + + $result = $query->execute(); $readOnlyPropertyName = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only'; while ($row = $result->fetch()) { + $row['principaluri'] = (string) $row['principaluri']; if ($row['principaluri'] === $principalUri) { continue; } @@ -427,6 +441,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $stmt = $query->execute(); $calendars = []; while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + $row['principaluri'] = (string) $row['principaluri']; $components = []; if ($row['components']) { $components = explode(',',$row['components']); @@ -496,6 +511,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription ->execute(); while ($row = $result->fetch()) { + $row['principaluri'] = (string) $row['principaluri']; list(, $name) = Uri\split($row['principaluri']); $row['displayname'] = $row['displayname'] . "($name)"; $components = []; @@ -562,6 +578,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription throw new NotFound('Node with name \'' . $uri . '\' could not be found'); } + $row['principaluri'] = (string) $row['principaluri']; list(, $name) = Uri\split($row['principaluri']); $row['displayname'] = $row['displayname'] . ' ' . "($name)"; $components = []; @@ -618,6 +635,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription return null; } + $row['principaluri'] = (string) $row['principaluri']; $components = []; if ($row['components']) { $components = explode(',',$row['components']); @@ -668,6 +686,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription return null; } + $row['principaluri'] = (string) $row['principaluri']; $components = []; if ($row['components']) { $components = explode(',',$row['components']); @@ -717,6 +736,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription return null; } + $row['principaluri'] = (string) $row['principaluri']; $subscription = [ 'id' => $row['id'], 'uri' => $row['uri'], @@ -964,6 +984,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription 'classification'=> (int)$row['classification'] ]; } + $stmt->closeCursor(); return $result; } @@ -994,6 +1015,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription ->andWhere($query->expr()->eq('calendartype', $query->createNamedParameter($calendarType))); $stmt = $query->execute(); $row = $stmt->fetch(\PDO::FETCH_ASSOC); + $stmt->closeCursor(); if (!$row) { return null; From 97b040298489e44416b45f6521c5ce0353d554ac Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 9 Nov 2020 16:26:09 +0100 Subject: [PATCH 09/19] Empty string is returned as null, but empty string in file cache is the root and exists Signed-off-by: Joas Schilling --- lib/private/Files/Cache/Cache.php | 6 +++++- lib/private/Share20/DefaultShareProvider.php | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index e74cc86d9c9..1d3b4da3bce 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -998,7 +998,11 @@ class Cache implements ICache { $path = $result->fetchColumn(); $result->closeCursor(); - return $path === false ? null : $path; + if ($path === false) { + return null; + } + + return (string) $path; } /** diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index e43529086fd..b4ac3b3b84d 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -874,6 +874,11 @@ class DefaultShareProvider implements IShareProvider { $cursor = $qb->execute(); while ($data = $cursor->fetch()) { + if ($data['fileid'] && $data['path'] === null) { + $data['path'] = (string) $data['path']; + $data['name'] = (string) $data['name']; + $data['checksum'] = (string) $data['checksum']; + } if ($this->isAccessibleResult($data)) { $shares[] = $this->createShare($data); } @@ -1004,7 +1009,7 @@ class DefaultShareProvider implements IShareProvider { ->setShareType((int)$data['share_type']) ->setPermissions((int)$data['permissions']) ->setTarget($data['file_target']) - ->setNote($data['note']) + ->setNote((string)$data['note']) ->setMailSend((bool)$data['mail_send']) ->setStatus((int)$data['accepted']) ->setLabel($data['label']); From a66591ee79e5d9a34b0092c79856129e1a49fb6d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 9 Nov 2020 17:33:05 +0100 Subject: [PATCH 10/19] Fix comparing the empty string for global credentials Signed-off-by: Joas Schilling --- lib/private/DB/Connection.php | 16 +++++++++++----- lib/private/Security/CredentialsManager.php | 21 +++++++++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index 4d390a04ec5..17e76c37b33 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -307,11 +307,17 @@ class Connection extends ReconnectWrapper implements IDBConnection { $where = $updateQb->expr()->andX(); $whereValues = array_merge($keys, $updatePreconditionValues); foreach ($whereValues as $name => $value) { - $where->add($updateQb->expr()->eq( - $name, - $updateQb->createNamedParameter($value, $this->getType($value)), - $this->getType($value) - )); + if ($value === '') { + $where->add($updateQb->expr()->emptyString( + $name + )); + } else { + $where->add($updateQb->expr()->eq( + $name, + $updateQb->createNamedParameter($value, $this->getType($value)), + $this->getType($value) + )); + } } $updateQb->where($where); $affected = $updateQb->execute(); diff --git a/lib/private/Security/CredentialsManager.php b/lib/private/Security/CredentialsManager.php index a40a7e1d88e..20af25ae10f 100644 --- a/lib/private/Security/CredentialsManager.php +++ b/lib/private/Security/CredentialsManager.php @@ -81,9 +81,13 @@ class CredentialsManager implements ICredentialsManager { $qb = $this->dbConnection->getQueryBuilder(); $qb->select('credentials') ->from(self::DB_TABLE) - ->where($qb->expr()->eq('user', $qb->createNamedParameter((string)$userId))) - ->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier))) - ; + ->where($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier))); + + if ($userId === '') { + $qb->andWhere($qb->expr()->emptyString('user')); + } else { + $qb->andWhere($qb->expr()->eq('user', $qb->createNamedParameter((string)$userId))); + } $qResult = $qb->execute(); $result = $qResult->fetch(); @@ -107,9 +111,14 @@ class CredentialsManager implements ICredentialsManager { public function delete($userId, $identifier) { $qb = $this->dbConnection->getQueryBuilder(); $qb->delete(self::DB_TABLE) - ->where($qb->expr()->eq('user', $qb->createNamedParameter((string)$userId))) - ->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier))) - ; + ->where($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier))); + + if ($userId === '') { + $qb->andWhere($qb->expr()->emptyString('user')); + } else { + $qb->andWhere($qb->expr()->eq('user', $qb->createNamedParameter((string)$userId))); + } + return $qb->execute(); } From dee42027ed1008e28bf20a7dad91f33b8072ba9c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 9 Nov 2020 17:33:32 +0100 Subject: [PATCH 11/19] Don't try to update on NotNullConstraintViolationException, only on unique or foreign key Signed-off-by: Joas Schilling --- lib/private/DB/Connection.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index 17e76c37b33..81b5e4feabf 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -39,6 +39,7 @@ use Doctrine\DBAL\Configuration; use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Exception\ConstraintViolationException; +use Doctrine\DBAL\Exception\NotNullConstraintViolationException; use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Schema\Schema; use OC\DB\QueryBuilder\QueryBuilder; @@ -297,6 +298,8 @@ class Connection extends ReconnectWrapper implements IDBConnection { }, array_merge($keys, $values)) ); return $insertQb->execute(); + } catch (NotNullConstraintViolationException $e) { + throw $e; } catch (ConstraintViolationException $e) { // value already exists, try update $updateQb = $this->getQueryBuilder(); From f3c183b6c30bf9b738d2ff57726f414430775b59 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 10 Nov 2020 09:33:29 +0100 Subject: [PATCH 12/19] Replace the credentials table with one that can have empty user Primary key columns on Oracle can not have empty strings Signed-off-by: Joas Schilling --- .../Version13000Date20170718121200.php | 32 +++--- .../Version20000Date20201109081915.php | 2 +- .../Version20000Date20201109081918.php | 107 ++++++++++++++++++ .../Version20000Date20201109081919.php | 52 +++++++++ lib/composer/composer/autoload_classmap.php | 2 + lib/composer/composer/autoload_static.php | 2 + lib/private/Security/CredentialsManager.php | 2 +- version.php | 2 +- 8 files changed, 182 insertions(+), 19 deletions(-) create mode 100644 core/Migrations/Version20000Date20201109081918.php create mode 100644 core/Migrations/Version20000Date20201109081919.php diff --git a/core/Migrations/Version13000Date20170718121200.php b/core/Migrations/Version13000Date20170718121200.php index fcea6657b30..ae4b34ec9fb 100644 --- a/core/Migrations/Version13000Date20170718121200.php +++ b/core/Migrations/Version13000Date20170718121200.php @@ -810,22 +810,22 @@ class Version13000Date20170718121200 extends SimpleMigrationStep { $table->addUniqueIndex(['user_id', 'object_type', 'object_id'], 'comments_marker_index'); } - if (!$schema->hasTable('credentials')) { - $table = $schema->createTable('credentials'); - $table->addColumn('user', 'string', [ - 'notnull' => false, - 'length' => 64, - ]); - $table->addColumn('identifier', 'string', [ - 'notnull' => true, - 'length' => 64, - ]); - $table->addColumn('credentials', 'text', [ - 'notnull' => false, - ]); - $table->setPrimaryKey(['user', 'identifier']); - $table->addIndex(['user'], 'credentials_user'); - } +// if (!$schema->hasTable('credentials')) { +// $table = $schema->createTable('credentials'); +// $table->addColumn('user', 'string', [ +// 'notnull' => false, +// 'length' => 64, +// ]); +// $table->addColumn('identifier', 'string', [ +// 'notnull' => true, +// 'length' => 64, +// ]); +// $table->addColumn('credentials', 'text', [ +// 'notnull' => false, +// ]); +// $table->setPrimaryKey(['user', 'identifier']); +// $table->addIndex(['user'], 'credentials_user'); +// } if (!$schema->hasTable('admin_sections')) { $table = $schema->createTable('admin_sections'); diff --git a/core/Migrations/Version20000Date20201109081915.php b/core/Migrations/Version20000Date20201109081915.php index 720f54d8e8b..d19c9ca0bb2 100644 --- a/core/Migrations/Version20000Date20201109081915.php +++ b/core/Migrations/Version20000Date20201109081915.php @@ -43,7 +43,7 @@ class Version20000Date20201109081915 extends SimpleMigrationStep { $result = $this->ensureColumnIsNullable($schema, 'share', 'password_by_talk'); $result = $this->ensureColumnIsNullable($schema, 'share', 'hide_download') || $result; - $result = $this->ensureColumnIsNullable($schema, 'credentials', 'user') || $result; +// $result = $this->ensureColumnIsNullable($schema, 'credentials', 'user') || $result; $result = $this->ensureColumnIsNullable($schema, 'authtoken', 'password_invalid') || $result; $result = $this->ensureColumnIsNullable($schema, 'collres_accesscache', 'access') || $result; diff --git a/core/Migrations/Version20000Date20201109081918.php b/core/Migrations/Version20000Date20201109081918.php new file mode 100644 index 00000000000..8e685b200ab --- /dev/null +++ b/core/Migrations/Version20000Date20201109081918.php @@ -0,0 +1,107 @@ + + * + * @author Joas Schilling + * + * @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 OC\Core\Migrations; + +use Closure; +use Doctrine\DBAL\Types\Type; +use OCP\DB\ISchemaWrapper; +use OCP\IDBConnection; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +class Version20000Date20201109081918 extends SimpleMigrationStep { + + /** @var IDBConnection */ + protected $connection; + + public function __construct(IDBConnection $connection) { + $this->connection = $connection; + } + + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + $table = $schema->createTable('storages_credentials'); + $table->addColumn('id', Type::BIGINT, [ + 'autoincrement' => true, + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('user', Type::STRING, [ + 'notnull' => false, + 'length' => 64, + ]); + $table->addColumn('identifier', Type::STRING, [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('credentials', Type::TEXT, [ + 'notnull' => false, + ]); + $table->setPrimaryKey(['id']); + $table->addUniqueIndex(['user', 'identifier'], 'stocred_ui'); + $table->addIndex(['user'], 'stocred_user'); + + return $schema; + } + + /** + * {@inheritDoc} + * + * @since 13.0.0 + */ + public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { + if (!$this->connection->tableExists('credentials')) { + return; + } + + $query = $this->connection->getQueryBuilder(); + $query->select('*') + ->from('credentials'); + + $insert = $this->connection->getQueryBuilder(); + $insert->insert('storages_credentials') + ->setValue('user', $insert->createNamedParameter('user')) + ->setValue('identifier', $insert->createNamedParameter('identifier')) + ->setValue('credentials', $insert->createNamedParameter('credentials')); + + $result = $query->execute(); + while ($row = $result->fetch()) { + $insert->setParameter('user', (string) $row['user']) + ->setParameter('identifier', (string) $row['identifier']) + ->setParameter('credentials', (string) $row['credentials']); + $insert->execute(); + } + $result->closeCursor(); + } +} diff --git a/core/Migrations/Version20000Date20201109081919.php b/core/Migrations/Version20000Date20201109081919.php new file mode 100644 index 00000000000..bfc7080ab40 --- /dev/null +++ b/core/Migrations/Version20000Date20201109081919.php @@ -0,0 +1,52 @@ + + * + * @author Joas Schilling + * + * @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 OC\Core\Migrations; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +class Version20000Date20201109081919 extends SimpleMigrationStep { + + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + if ($schema->hasTable('credentials')) { + $schema->dropTable('credentials'); + return $schema; + } + + return null; + } +} diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 48f9f60999d..c214e42c61a 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -920,6 +920,8 @@ return array( 'OC\\Core\\Migrations\\Version18000Date20191204114856' => $baseDir . '/core/Migrations/Version18000Date20191204114856.php', 'OC\\Core\\Migrations\\Version19000Date20200211083441' => $baseDir . '/core/Migrations/Version19000Date20200211083441.php', 'OC\\Core\\Migrations\\Version20000Date20201109081915' => $baseDir . '/core/Migrations/Version20000Date20201109081915.php', + 'OC\\Core\\Migrations\\Version20000Date20201109081918' => $baseDir . '/core/Migrations/Version20000Date20201109081918.php', + 'OC\\Core\\Migrations\\Version20000Date20201109081919' => $baseDir . '/core/Migrations/Version20000Date20201109081919.php', 'OC\\Core\\Notification\\RemoveLinkSharesNotifier' => $baseDir . '/core/Notification/RemoveLinkSharesNotifier.php', 'OC\\Core\\Service\\LoginFlowV2Service' => $baseDir . '/core/Service/LoginFlowV2Service.php', 'OC\\DB\\Adapter' => $baseDir . '/lib/private/DB/Adapter.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index c6f23f18523..328c580e88f 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -949,6 +949,8 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Core\\Migrations\\Version18000Date20191204114856' => __DIR__ . '/../../..' . '/core/Migrations/Version18000Date20191204114856.php', 'OC\\Core\\Migrations\\Version19000Date20200211083441' => __DIR__ . '/../../..' . '/core/Migrations/Version19000Date20200211083441.php', 'OC\\Core\\Migrations\\Version20000Date20201109081915' => __DIR__ . '/../../..' . '/core/Migrations/Version20000Date20201109081915.php', + 'OC\\Core\\Migrations\\Version20000Date20201109081918' => __DIR__ . '/../../..' . '/core/Migrations/Version20000Date20201109081918.php', + 'OC\\Core\\Migrations\\Version20000Date20201109081919' => __DIR__ . '/../../..' . '/core/Migrations/Version20000Date20201109081919.php', 'OC\\Core\\Notification\\RemoveLinkSharesNotifier' => __DIR__ . '/../../..' . '/core/Notification/RemoveLinkSharesNotifier.php', 'OC\\Core\\Service\\LoginFlowV2Service' => __DIR__ . '/../../..' . '/core/Service/LoginFlowV2Service.php', 'OC\\DB\\Adapter' => __DIR__ . '/../../..' . '/lib/private/DB/Adapter.php', diff --git a/lib/private/Security/CredentialsManager.php b/lib/private/Security/CredentialsManager.php index 20af25ae10f..2a480ef7105 100644 --- a/lib/private/Security/CredentialsManager.php +++ b/lib/private/Security/CredentialsManager.php @@ -35,7 +35,7 @@ use OCP\Security\ICrypto; * @package OC\Security */ class CredentialsManager implements ICredentialsManager { - public const DB_TABLE = 'credentials'; + public const DB_TABLE = 'storages_credentials'; /** @var ICrypto */ protected $crypto; diff --git a/version.php b/version.php index f971a54fa15..60bb166006f 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ // between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel // when updating major/minor version number. -$OC_Version = [20, 0, 1, 4]; +$OC_Version = [20, 0, 1, 5]; // The human readable string $OC_VersionString = '20.0.1'; From bb52911d1604e3e01731861cbe196fdc93e33ce0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 10 Nov 2020 09:34:57 +0100 Subject: [PATCH 13/19] Create primary keys on all tables and add a command to create the afterwards Signed-off-by: Joas Schilling --- .../Version1010Date20200630191755.php | 3 +- .../lib/Controller/CheckSetupController.php | 11 ++ .../Controller/CheckSetupControllerTest.php | 5 + core/Application.php | 58 ++++++ core/Command/Db/AddMissingPrimaryKeys.php | 181 ++++++++++++++++++ .../Version13000Date20170718121200.php | 6 +- .../Version16000Date20190207141427.php | 6 +- .../Version17000Date20190514105811.php | 3 +- .../Version18000Date20191204114856.php | 1 - core/js/setupchecks.js | 15 ++ core/js/tests/specs/setupchecksSpec.js | 16 ++ lib/composer/composer/autoload_classmap.php | 2 + lib/composer/composer/autoload_static.php | 2 + .../DB/MissingPrimaryKeyInformation.php | 42 ++++ lib/public/IDBConnection.php | 2 + version.php | 2 +- 16 files changed, 347 insertions(+), 8 deletions(-) create mode 100644 core/Command/Db/AddMissingPrimaryKeys.php create mode 100644 lib/private/DB/MissingPrimaryKeyInformation.php diff --git a/apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php b/apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php index 53348d8f86d..bf0d0f8eecd 100644 --- a/apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php +++ b/apps/federatedfilesharing/lib/Migration/Version1010Date20200630191755.php @@ -52,7 +52,8 @@ class Version1010Date20200630191755 extends SimpleMigrationStep { 'notnull' => true, 'length' => 4, ]); - $table->addUniqueIndex(['share_id'], 'share_id_index'); + $table->setPrimaryKey(['share_id'], 'federated_res_pk'); +// $table->addUniqueIndex(['share_id'], 'share_id_index'); } return $schema; } diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 0c3d17d31eb..db8df5eb3e5 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -49,6 +49,7 @@ use OC\AppFramework\Http; use OC\DB\Connection; use OC\DB\MissingColumnInformation; use OC\DB\MissingIndexInformation; +use OC\DB\MissingPrimaryKeyInformation; use OC\DB\SchemaWrapper; use OC\IntegrityCheck\Checker; use OC\Lock\NoopLockingProvider; @@ -451,6 +452,15 @@ Raw output return $indexInfo->getListOfMissingIndexes(); } + protected function hasMissingPrimaryKeys(): array { + $info = new MissingPrimaryKeyInformation(); + // Dispatch event so apps can also hint for pending index updates if needed + $event = new GenericEvent($info); + $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_PRIMARY_KEYS_EVENT, $event); + + return $info->getListOfMissingPrimaryKeys(); + } + protected function hasMissingColumns(): array { $indexInfo = new MissingColumnInformation(); // Dispatch event so apps can also hint for pending index updates if needed @@ -719,6 +729,7 @@ Raw output 'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'), 'isSettimelimitAvailable' => $this->isSettimelimitAvailable(), 'hasFreeTypeSupport' => $this->hasFreeTypeSupport(), + 'missingPrimaryKeys' => $this->hasMissingPrimaryKeys(), 'missingIndexes' => $this->hasMissingIndexes(), 'missingColumns' => $this->hasMissingColumns(), 'isSqliteUsed' => $this->isSqliteUsed(), diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index 819c8edcca9..36552a894ba 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -165,6 +165,7 @@ class CheckSetupControllerTest extends TestCase { 'isOpcacheProperlySetup', 'hasFreeTypeSupport', 'hasMissingIndexes', + 'hasMissingPrimaryKeys', 'isSqliteUsed', 'isPHPMailerUsed', 'hasOpcacheLoaded', @@ -444,6 +445,9 @@ class CheckSetupControllerTest extends TestCase { $this->checkSetupController ->method('hasMissingIndexes') ->willReturn([]); + $this->checkSetupController + ->method('hasMissingPrimaryKeys') + ->willReturn([]); $this->checkSetupController ->method('isSqliteUsed') ->willReturn(false); @@ -587,6 +591,7 @@ class CheckSetupControllerTest extends TestCase { 'isSqliteUsed' => false, 'databaseConversionDocumentation' => 'http://docs.example.org/server/go.php?to=admin-db-conversion', 'missingIndexes' => [], + 'missingPrimaryKeys' => [], 'missingColumns' => [], 'isPHPMailerUsed' => false, 'mailSettingsDocumentation' => 'https://server/index.php/settings/admin', diff --git a/core/Application.php b/core/Application.php index 9f0fa4092a2..f105dfd25d1 100644 --- a/core/Application.php +++ b/core/Application.php @@ -42,6 +42,7 @@ use OC\Authentication\Notifications\Notifier as AuthenticationNotifier; use OC\Core\Notification\RemoveLinkSharesNotifier; use OC\DB\MissingColumnInformation; use OC\DB\MissingIndexInformation; +use OC\DB\MissingPrimaryKeyInformation; use OC\DB\SchemaWrapper; use OCP\AppFramework\App; use OCP\EventDispatcher\IEventDispatcher; @@ -177,6 +178,63 @@ class Application extends App { } ); + $oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_PRIMARY_KEYS_EVENT, + function (GenericEvent $event) use ($container) { + /** @var MissingPrimaryKeyInformation $subject */ + $subject = $event->getSubject(); + + $schema = new SchemaWrapper($container->query(IDBConnection::class)); + + if ($schema->hasTable('federated_reshares')) { + $table = $schema->getTable('federated_reshares'); + + if (!$table->hasPrimaryKey()) { + $subject->addHintForMissingSubject($table->getName()); + } + } + + if ($schema->hasTable('systemtag_object_mapping')) { + $table = $schema->getTable('systemtag_object_mapping'); + + if (!$table->hasPrimaryKey()) { + $subject->addHintForMissingSubject($table->getName()); + } + } + + if ($schema->hasTable('comments_read_markers')) { + $table = $schema->getTable('comments_read_markers'); + + if (!$table->hasPrimaryKey()) { + $subject->addHintForMissingSubject($table->getName()); + } + } + + if ($schema->hasTable('collres_resources')) { + $table = $schema->getTable('collres_resources'); + + if (!$table->hasPrimaryKey()) { + $subject->addHintForMissingSubject($table->getName()); + } + } + + if ($schema->hasTable('collres_accesscache')) { + $table = $schema->getTable('collres_accesscache'); + + if (!$table->hasPrimaryKey()) { + $subject->addHintForMissingSubject($table->getName()); + } + } + + if ($schema->hasTable('filecache_extended')) { + $table = $schema->getTable('filecache_extended'); + + if (!$table->hasPrimaryKey()) { + $subject->addHintForMissingSubject($table->getName()); + } + } + } + ); + $oldEventDispatcher->addListener(IDBConnection::CHECK_MISSING_COLUMNS_EVENT, function (GenericEvent $event) use ($container) { /** @var MissingColumnInformation $subject */ diff --git a/core/Command/Db/AddMissingPrimaryKeys.php b/core/Command/Db/AddMissingPrimaryKeys.php new file mode 100644 index 00000000000..a51249b1b8b --- /dev/null +++ b/core/Command/Db/AddMissingPrimaryKeys.php @@ -0,0 +1,181 @@ + + * + * @author Bjoern Schiessle + * @author Joas Schilling + * @author Mario Danic + * @author Morris Jobke + * @author Robin Appelman + * @author Roeland Jago Douma + * @author Thomas Citharel + * + * @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 OC\Core\Command\Db; + +use OC\DB\SchemaWrapper; +use OCP\IDBConnection; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\GenericEvent; + +/** + * Class AddMissingPrimaryKeys + * + * if you added primary keys to the database, this is the right place to add + * your update routine for existing instances + * + * @package OC\Core\Command\Db + */ +class AddMissingPrimaryKeys extends Command { + + /** @var IDBConnection */ + private $connection; + + /** @var EventDispatcherInterface */ + private $dispatcher; + + public function __construct(IDBConnection $connection, EventDispatcherInterface $dispatcher) { + parent::__construct(); + + $this->connection = $connection; + $this->dispatcher = $dispatcher; + } + + protected function configure() { + $this + ->setName('db:add-missing-primary-keys') + ->setDescription('Add missing primary keys to the database tables'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int { + $this->addCorePrimaryKeys($output); + + // Dispatch event so apps can also update indexes if needed + $event = new GenericEvent($output); + $this->dispatcher->dispatch(IDBConnection::ADD_MISSING_PRIMARY_KEYS_EVENT, $event); + return 0; + } + + /** + * add missing indices to the share table + * + * @param OutputInterface $output + * @throws \Doctrine\DBAL\Schema\SchemaException + */ + private function addCorePrimaryKeys(OutputInterface $output) { + $output->writeln('Check primary keys.'); + + $schema = new SchemaWrapper($this->connection); + $updated = false; + + if ($schema->hasTable('federated_reshares')) { + $table = $schema->getTable('federated_reshares'); + if (!$table->hasPrimaryKey()) { + $output->writeln('Adding primary key to the federated_reshares table, this can take some time...'); + $table->setPrimaryKey(['share_id'], 'federated_res_pk'); + if ($table->hasIndex('share_id_index')) { + $table->dropIndex('share_id_index'); + } + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('federated_reshares table updated successfully.'); + } + } + + if ($schema->hasTable('systemtag_object_mapping')) { + $table = $schema->getTable('systemtag_object_mapping'); + if (!$table->hasPrimaryKey()) { + $output->writeln('Adding primary key to the systemtag_object_mapping table, this can take some time...'); + $table->setPrimaryKey(['objecttype', 'objectid', 'systemtagid'], 'som_pk'); + if ($table->hasIndex('mapping')) { + $table->dropIndex('mapping'); + } + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('systemtag_object_mapping table updated successfully.'); + } + } + + if ($schema->hasTable('comments_read_markers')) { + $table = $schema->getTable('comments_read_markers'); + if (!$table->hasPrimaryKey()) { + $output->writeln('Adding primary key to the comments_read_markers table, this can take some time...'); + $table->setPrimaryKey(['user_id', 'object_type', 'object_id'], 'crm_pk'); + if ($table->hasIndex('comments_marker_index')) { + $table->dropIndex('comments_marker_index'); + } + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('comments_read_markers table updated successfully.'); + } + } + + if ($schema->hasTable('collres_resources')) { + $table = $schema->getTable('collres_resources'); + if (!$table->hasPrimaryKey()) { + $output->writeln('Adding primary key to the collres_resources table, this can take some time...'); + $table->setPrimaryKey(['collection_id', 'resource_type', 'resource_id'], 'crr_pk'); + if ($table->hasIndex('collres_unique_res')) { + $table->dropIndex('collres_unique_res'); + } + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('collres_resources table updated successfully.'); + } + } + + if ($schema->hasTable('collres_accesscache')) { + $table = $schema->getTable('collres_accesscache'); + if (!$table->hasPrimaryKey()) { + $output->writeln('Adding primary key to the collres_accesscache table, this can take some time...'); + $table->setPrimaryKey(['user_id', 'collection_id', 'resource_type', 'resource_id'], 'cra_pk'); + if ($table->hasIndex('collres_unique_user')) { + $table->dropIndex('collres_unique_user'); + } + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('collres_accesscache table updated successfully.'); + } + } + + if ($schema->hasTable('filecache_extended')) { + $table = $schema->getTable('filecache_extended'); + if (!$table->hasPrimaryKey()) { + $output->writeln('Adding primary key to the filecache_extended table, this can take some time...'); + $table->setPrimaryKey(['fileid'], 'fce_pk'); + if ($table->hasIndex('fce_fileid_idx')) { + $table->dropIndex('fce_fileid_idx'); + } + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('filecache_extended table updated successfully.'); + } + } + + if (!$updated) { + $output->writeln('Done.'); + } + } +} diff --git a/core/Migrations/Version13000Date20170718121200.php b/core/Migrations/Version13000Date20170718121200.php index ae4b34ec9fb..6b252d8b830 100644 --- a/core/Migrations/Version13000Date20170718121200.php +++ b/core/Migrations/Version13000Date20170718121200.php @@ -672,7 +672,8 @@ class Version13000Date20170718121200 extends SimpleMigrationStep { 'default' => 0, 'unsigned' => true, ]); - $table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping'); + $table->setPrimaryKey(['objecttype', 'objectid', 'systemtagid'], 'som_pk'); +// $table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping'); } if (!$schema->hasTable('systemtag_group')) { @@ -807,7 +808,8 @@ class Version13000Date20170718121200 extends SimpleMigrationStep { 'default' => '', ]); $table->addIndex(['object_type', 'object_id'], 'comments_marker_object_index'); - $table->addUniqueIndex(['user_id', 'object_type', 'object_id'], 'comments_marker_index'); + $table->setPrimaryKey(['user_id', 'object_type', 'object_id'], 'crm_pk'); +// $table->addUniqueIndex(['user_id', 'object_type', 'object_id'], 'comments_marker_index'); } // if (!$schema->hasTable('credentials')) { diff --git a/core/Migrations/Version16000Date20190207141427.php b/core/Migrations/Version16000Date20190207141427.php index 63c6c871eae..77a41dc3c4f 100644 --- a/core/Migrations/Version16000Date20190207141427.php +++ b/core/Migrations/Version16000Date20190207141427.php @@ -77,7 +77,8 @@ class Version16000Date20190207141427 extends SimpleMigrationStep { 'length' => 64, ]); - $table->addUniqueIndex(['collection_id', 'resource_type', 'resource_id'], 'collres_unique_res'); + $table->setPrimaryKey(['collection_id', 'resource_type', 'resource_id'], 'crr_pk'); +// $table->addUniqueIndex(['collection_id', 'resource_type', 'resource_id'], 'collres_unique_res'); } if (!$schema->hasTable('collres_accesscache')) { @@ -106,7 +107,8 @@ class Version16000Date20190207141427 extends SimpleMigrationStep { 'default' => 0, ]); - $table->addUniqueIndex(['user_id', 'collection_id', 'resource_type', 'resource_id'], 'collres_unique_user'); + $table->setPrimaryKey(['user_id', 'collection_id', 'resource_type', 'resource_id'], 'cra_pk'); +// $table->addUniqueIndex(['user_id', 'collection_id', 'resource_type', 'resource_id'], 'collres_unique_user'); $table->addIndex(['user_id', 'resource_type', 'resource_id'], 'collres_user_res'); $table->addIndex(['user_id', 'collection_id'], 'collres_user_coll'); } diff --git a/core/Migrations/Version17000Date20190514105811.php b/core/Migrations/Version17000Date20190514105811.php index 910d8216070..bd6ab1bc8a5 100644 --- a/core/Migrations/Version17000Date20190514105811.php +++ b/core/Migrations/Version17000Date20190514105811.php @@ -67,7 +67,8 @@ class Version17000Date20190514105811 extends SimpleMigrationStep { 'length' => 20, 'default' => 0, ]); - $table->addUniqueIndex(['fileid'], 'fce_fileid_idx'); + $table->setPrimaryKey(['fileid'], 'fce_pk'); +// $table->addUniqueIndex(['fileid'], 'fce_fileid_idx'); $table->addIndex(['creation_time'], 'fce_ctime_idx'); $table->addIndex(['upload_time'], 'fce_utime_idx'); } diff --git a/core/Migrations/Version18000Date20191204114856.php b/core/Migrations/Version18000Date20191204114856.php index e9bf1221dbf..0e5f3cbe272 100644 --- a/core/Migrations/Version18000Date20191204114856.php +++ b/core/Migrations/Version18000Date20191204114856.php @@ -58,7 +58,6 @@ class Version18000Date20191204114856 extends SimpleMigrationStep { 'length' => 4000, ]); - return $schema; } } diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index 4773a201535..1541729eb8c 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -357,6 +357,21 @@ type: OC.SetupChecks.MESSAGE_TYPE_INFO }) } + if (data.missingPrimaryKeys.length > 0) { + var listOfMissingPrimaryKeys = ""; + data.missingPrimaryKeys.forEach(function(element){ + listOfMissingPrimaryKeys += "
  • "; + listOfMissingPrimaryKeys += t('core', 'Missing primary key on table "{tableName}".', element); + listOfMissingPrimaryKeys += "
  • "; + }); + messages.push({ + msg: t( + 'core', + 'The database is missing some primary keys. Due to the fact that adding primary keys on big tables could take some time they were not added automatically. By running "occ db:add-missing-primary-keys" those missing primary keys could be added manually while the instance keeps running.' + ) + "
      " + listOfMissingPrimaryKeys + "
    ", + type: OC.SetupChecks.MESSAGE_TYPE_INFO + }) + } if (data.missingColumns.length > 0) { var listOfMissingColumns = ""; data.missingColumns.forEach(function(element){ diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index f4c81c6bf78..3b54a3ff66a 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -240,6 +240,7 @@ describe('OC.SetupChecks tests', function() { isSettimelimitAvailable: true, hasFreeTypeSupport: true, missingIndexes: [], + missingPrimaryKeys: [], missingColumns: [], cronErrors: [], cronInfo: { @@ -294,6 +295,7 @@ describe('OC.SetupChecks tests', function() { isSettimelimitAvailable: true, hasFreeTypeSupport: true, missingIndexes: [], + missingPrimaryKeys: [], missingColumns: [], cronErrors: [], cronInfo: { @@ -349,6 +351,7 @@ describe('OC.SetupChecks tests', function() { isSettimelimitAvailable: true, hasFreeTypeSupport: true, missingIndexes: [], + missingPrimaryKeys: [], missingColumns: [], cronErrors: [], cronInfo: { @@ -402,6 +405,7 @@ describe('OC.SetupChecks tests', function() { isSettimelimitAvailable: true, hasFreeTypeSupport: true, missingIndexes: [], + missingPrimaryKeys: [], missingColumns: [], cronErrors: [], cronInfo: { @@ -453,6 +457,7 @@ describe('OC.SetupChecks tests', function() { isSettimelimitAvailable: true, hasFreeTypeSupport: true, missingIndexes: [], + missingPrimaryKeys: [], missingColumns: [], cronErrors: [], cronInfo: { @@ -504,6 +509,7 @@ describe('OC.SetupChecks tests', function() { isSettimelimitAvailable: true, hasFreeTypeSupport: true, missingIndexes: [], + missingPrimaryKeys: [], missingColumns: [], cronErrors: [], cronInfo: { @@ -557,6 +563,7 @@ describe('OC.SetupChecks tests', function() { isSettimelimitAvailable: true, hasFreeTypeSupport: true, missingIndexes: [], + missingPrimaryKeys: [], missingColumns: [], cronErrors: [], cronInfo: { @@ -608,6 +615,7 @@ describe('OC.SetupChecks tests', function() { isSettimelimitAvailable: false, hasFreeTypeSupport: true, missingIndexes: [], + missingPrimaryKeys: [], missingColumns: [], cronErrors: [], cronInfo: { @@ -659,6 +667,7 @@ describe('OC.SetupChecks tests', function() { isSettimelimitAvailable: true, hasFreeTypeSupport: true, missingIndexes: [], + missingPrimaryKeys: [], missingColumns: [], cronErrors: [], cronInfo: { @@ -731,6 +740,7 @@ describe('OC.SetupChecks tests', function() { isSettimelimitAvailable: true, hasFreeTypeSupport: true, missingIndexes: [], + missingPrimaryKeys: [], missingColumns: [], cronErrors: [], cronInfo: { @@ -783,6 +793,7 @@ describe('OC.SetupChecks tests', function() { isSettimelimitAvailable: true, hasFreeTypeSupport: true, missingIndexes: [], + missingPrimaryKeys: [], missingColumns: [], cronErrors: [], cronInfo: { @@ -835,6 +846,7 @@ describe('OC.SetupChecks tests', function() { isSettimelimitAvailable: true, hasFreeTypeSupport: true, missingIndexes: [], + missingPrimaryKeys: [], missingColumns: [], cronErrors: [], cronInfo: { @@ -887,6 +899,7 @@ describe('OC.SetupChecks tests', function() { isSettimelimitAvailable: true, hasFreeTypeSupport: false, missingIndexes: [], + missingPrimaryKeys: [], missingColumns: [], cronErrors: [], cronInfo: { @@ -938,6 +951,7 @@ describe('OC.SetupChecks tests', function() { isSettimelimitAvailable: true, hasFreeTypeSupport: true, missingIndexes: [], + missingPrimaryKeys: [], missingColumns: [], cronErrors: [], cronInfo: { @@ -989,6 +1003,7 @@ describe('OC.SetupChecks tests', function() { isSettimelimitAvailable: true, hasFreeTypeSupport: true, missingIndexes: [], + missingPrimaryKeys: [], missingColumns: [], cronErrors: [], cronInfo: { @@ -1041,6 +1056,7 @@ describe('OC.SetupChecks tests', function() { isSettimelimitAvailable: true, hasFreeTypeSupport: true, missingIndexes: [], + missingPrimaryKeys: [], missingColumns: [], cronErrors: [], cronInfo: { diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index c214e42c61a..55994589b36 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -796,6 +796,7 @@ return array( 'OC\\Core\\Command\\Config\\System\\SetConfig' => $baseDir . '/core/Command/Config/System/SetConfig.php', 'OC\\Core\\Command\\Db\\AddMissingColumns' => $baseDir . '/core/Command/Db/AddMissingColumns.php', 'OC\\Core\\Command\\Db\\AddMissingIndices' => $baseDir . '/core/Command/Db/AddMissingIndices.php', + 'OC\\Core\\Command\\Db\\AddMissingPrimaryKeys' => $baseDir . '/core/Command/Db/AddMissingPrimaryKeys.php', 'OC\\Core\\Command\\Db\\ConvertFilecacheBigInt' => $baseDir . '/core/Command/Db/ConvertFilecacheBigInt.php', 'OC\\Core\\Command\\Db\\ConvertMysqlToMB4' => $baseDir . '/core/Command/Db/ConvertMysqlToMB4.php', 'OC\\Core\\Command\\Db\\ConvertType' => $baseDir . '/core/Command/Db/ConvertType.php', @@ -939,6 +940,7 @@ return array( 'OC\\DB\\Migrator' => $baseDir . '/lib/private/DB/Migrator.php', 'OC\\DB\\MissingColumnInformation' => $baseDir . '/lib/private/DB/MissingColumnInformation.php', 'OC\\DB\\MissingIndexInformation' => $baseDir . '/lib/private/DB/MissingIndexInformation.php', + 'OC\\DB\\MissingPrimaryKeyInformation' => $baseDir . '/lib/private/DB/MissingPrimaryKeyInformation.php', 'OC\\DB\\MySQLMigrator' => $baseDir . '/lib/private/DB/MySQLMigrator.php', 'OC\\DB\\MySqlTools' => $baseDir . '/lib/private/DB/MySqlTools.php', 'OC\\DB\\OCSqlitePlatform' => $baseDir . '/lib/private/DB/OCSqlitePlatform.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 328c580e88f..8bf9bc42b34 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -825,6 +825,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Core\\Command\\Config\\System\\SetConfig' => __DIR__ . '/../../..' . '/core/Command/Config/System/SetConfig.php', 'OC\\Core\\Command\\Db\\AddMissingColumns' => __DIR__ . '/../../..' . '/core/Command/Db/AddMissingColumns.php', 'OC\\Core\\Command\\Db\\AddMissingIndices' => __DIR__ . '/../../..' . '/core/Command/Db/AddMissingIndices.php', + 'OC\\Core\\Command\\Db\\AddMissingPrimaryKeys' => __DIR__ . '/../../..' . '/core/Command/Db/AddMissingPrimaryKeys.php', 'OC\\Core\\Command\\Db\\ConvertFilecacheBigInt' => __DIR__ . '/../../..' . '/core/Command/Db/ConvertFilecacheBigInt.php', 'OC\\Core\\Command\\Db\\ConvertMysqlToMB4' => __DIR__ . '/../../..' . '/core/Command/Db/ConvertMysqlToMB4.php', 'OC\\Core\\Command\\Db\\ConvertType' => __DIR__ . '/../../..' . '/core/Command/Db/ConvertType.php', @@ -968,6 +969,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\DB\\Migrator' => __DIR__ . '/../../..' . '/lib/private/DB/Migrator.php', 'OC\\DB\\MissingColumnInformation' => __DIR__ . '/../../..' . '/lib/private/DB/MissingColumnInformation.php', 'OC\\DB\\MissingIndexInformation' => __DIR__ . '/../../..' . '/lib/private/DB/MissingIndexInformation.php', + 'OC\\DB\\MissingPrimaryKeyInformation' => __DIR__ . '/../../..' . '/lib/private/DB/MissingPrimaryKeyInformation.php', 'OC\\DB\\MySQLMigrator' => __DIR__ . '/../../..' . '/lib/private/DB/MySQLMigrator.php', 'OC\\DB\\MySqlTools' => __DIR__ . '/../../..' . '/lib/private/DB/MySqlTools.php', 'OC\\DB\\OCSqlitePlatform' => __DIR__ . '/../../..' . '/lib/private/DB/OCSqlitePlatform.php', diff --git a/lib/private/DB/MissingPrimaryKeyInformation.php b/lib/private/DB/MissingPrimaryKeyInformation.php new file mode 100644 index 00000000000..c6b81ddba4e --- /dev/null +++ b/lib/private/DB/MissingPrimaryKeyInformation.php @@ -0,0 +1,42 @@ + + * + * @author Morris Jobke + * @author Roeland Jago Douma + * + * @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 OC\DB; + +class MissingPrimaryKeyInformation { + private $listOfMissingPrimaryKeys = []; + + public function addHintForMissingSubject(string $tableName) { + $this->listOfMissingPrimaryKeys[] = [ + 'tableName' => $tableName, + ]; + } + + public function getListOfMissingPrimaryKeys(): array { + return $this->listOfMissingPrimaryKeys; + } +} diff --git a/lib/public/IDBConnection.php b/lib/public/IDBConnection.php index 4605a051e8a..07f22d39fa8 100644 --- a/lib/public/IDBConnection.php +++ b/lib/public/IDBConnection.php @@ -50,6 +50,8 @@ use OCP\DB\QueryBuilder\IQueryBuilder; interface IDBConnection { public const ADD_MISSING_INDEXES_EVENT = self::class . '::ADD_MISSING_INDEXES'; public const CHECK_MISSING_INDEXES_EVENT = self::class . '::CHECK_MISSING_INDEXES'; + public const ADD_MISSING_PRIMARY_KEYS_EVENT = self::class . '::ADD_MISSING_PRIMARY_KEYS'; + public const CHECK_MISSING_PRIMARY_KEYS_EVENT = self::class . '::CHECK_MISSING_PRIMARY_KEYS'; public const ADD_MISSING_COLUMNS_EVENT = self::class . '::ADD_MISSING_COLUMNS'; public const CHECK_MISSING_COLUMNS_EVENT = self::class . '::CHECK_MISSING_COLUMNS'; diff --git a/version.php b/version.php index 60bb166006f..a1e99bbbd75 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ // between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel // when updating major/minor version number. -$OC_Version = [20, 0, 1, 5]; +$OC_Version = [20, 0, 1, 6]; // The human readable string $OC_VersionString = '20.0.1'; From cd76043691ad460fe2aa710ea1ab77d3d5760c8f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 10 Nov 2020 15:43:34 +0100 Subject: [PATCH 14/19] Fix CS Signed-off-by: Joas Schilling --- apps/dav/lib/Migration/Version1016Date20201109085907.php | 1 + core/Migrations/Version20000Date20201109081915.php | 1 + core/Migrations/Version20000Date20201109081918.php | 1 + core/Migrations/Version20000Date20201109081919.php | 1 + 4 files changed, 4 insertions(+) diff --git a/apps/dav/lib/Migration/Version1016Date20201109085907.php b/apps/dav/lib/Migration/Version1016Date20201109085907.php index a43c8ae06a3..fd8996d5e22 100644 --- a/apps/dav/lib/Migration/Version1016Date20201109085907.php +++ b/apps/dav/lib/Migration/Version1016Date20201109085907.php @@ -1,4 +1,5 @@ Date: Tue, 10 Nov 2020 18:49:02 +0100 Subject: [PATCH 15/19] Fix naming of jobs and steps Signed-off-by: Joas Schilling --- .github/workflows/oci.yml | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/.github/workflows/oci.yml b/.github/workflows/oci.yml index 87cc1d41d44..5b545461e5d 100644 --- a/.github/workflows/oci.yml +++ b/.github/workflows/oci.yml @@ -1,17 +1,24 @@ -name: "Unit tests" +name: PHPUnit on: + pull_request: push: + branches: + - master + - stable* jobs: phpunit-oci8: - name: "PHPUnit on OCI8" - runs-on: "ubuntu-latest" + runs-on: ubuntu-latest strategy: + # do not stop on another job's failure + fail-fast: false matrix: - php-version: - - "7.4" + php-versions: [ '7.4' ] + databases: [ 'oci' ] + + name: php${{ matrix.php-versions }}-${{ matrix.databases }} services: oracle: @@ -20,8 +27,8 @@ jobs: - "1521:1521" steps: - - name: "Checkout" - uses: "actions/checkout@v2" + - name: Checkout server + uses: actions/checkout@v2 - name: Checkout submodules shell: bash @@ -30,10 +37,10 @@ jobs: git submodule sync --recursive git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@v2 with: - php-version: "${{ matrix.php-version }}" + php-version: ${{ matrix.php-versions }} extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite, oci8 tools: phpunit:8.5.2 coverage: none @@ -42,12 +49,8 @@ jobs: run: | mkdir data ./occ maintenance:install --verbose --database=oci --database-name=XE --database-host=127.0.0.1 --database-port=1521 --database-user=autotest --database-pass=owncloud --admin-user admin --admin-pass admin - - # Generate instance id by loading index.php - - name: Generate instance id by loading index.php - run: | php -f index.php - - name: Run phpunit - run: | - cd tests && phpunit --configuration phpunit-autotest.xml --group DB,SLOWDB + - name: PHPUnit + working-directory: tests + run: phpunit --configuration phpunit-autotest.xml --group DB,SLOWDB From dabed84bd4122b5936f51caa756dfa6857e0fc6f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 10 Nov 2020 19:21:08 +0100 Subject: [PATCH 16/19] Fix unique key in test table Signed-off-by: Joas Schilling --- tests/lib/DB/ConnectionTest.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/lib/DB/ConnectionTest.php b/tests/lib/DB/ConnectionTest.php index fa4d5fe005c..cab6133c3c0 100644 --- a/tests/lib/DB/ConnectionTest.php +++ b/tests/lib/DB/ConnectionTest.php @@ -220,13 +220,15 @@ class ConnectionTest extends \Test\TestCase { ['user' => 'test2', 'category' => 'Coworkers', 'expectedResult' => 1], ]; + $row = 0; foreach ($categoryEntries as $entry) { $result = $this->connection->insertIfNotExist('*PREFIX*table', [ 'textfield' => $entry['user'], 'clobfield' => $entry['category'], - ]); - $this->assertEquals($entry['expectedResult'], $result); + 'integerfield' => $row++, + ], ['textfield', 'clobfield']); + $this->assertEquals($entry['expectedResult'], $result, json_encode($entry)); } $query = $this->connection->prepare('SELECT * FROM `*PREFIX*table`'); @@ -247,13 +249,15 @@ class ConnectionTest extends \Test\TestCase { ['addressbookid' => 123, 'fullname' => 'test', 'expectedResult' => 1], ]; + $row = 0; foreach ($categoryEntries as $entry) { $result = $this->connection->insertIfNotExist('*PREFIX*table', [ 'integerfield_default' => $entry['addressbookid'], 'clobfield' => $entry['fullname'], - ]); - $this->assertEquals($entry['expectedResult'], $result); + 'integerfield' => $row++, + ], ['integerfield_default', 'clobfield']); + $this->assertEquals($entry['expectedResult'], $result, json_encode($entry)); } $query = $this->connection->prepare('SELECT * FROM `*PREFIX*table`'); From d09a22069fe25a0df9a00561d1c98e818800de8c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 11 Nov 2020 10:56:29 +0100 Subject: [PATCH 17/19] Update baseline, I'm sorry Signed-off-by: Joas Schilling --- build/psalm-baseline.xml | 218 ++++++--------------------------------- 1 file changed, 29 insertions(+), 189 deletions(-) diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index b83f8bd02a9..56f398dee96 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -202,11 +202,10 @@ - + $query->createParameter('principaluri') $query->createNamedParameter(self::ACCESS_PUBLIC) $query->createNamedParameter(self::ACCESS_PUBLIC) - $query->createNamedParameter($value) $query->createParameter('uri') $outerQuery->createFunction($innerQuery->getSQL()) $calendarObjectIdQuery->createNamedParameter($componentTypes, IQueryBuilder::PARAM_STR_ARRAY) @@ -1204,18 +1203,7 @@ - - $qb->createNamedParameter($shareType) - $qb->createNamedParameter($itemType) - $qb->createNamedParameter($itemSource) - $qb->createNamedParameter($itemSource) - $qb->createNamedParameter($shareWith) - $qb->createNamedParameter($uidOwner) - $qb->createNamedParameter($sharedBy) - $qb->createNamedParameter($permissions) - $qb->createNamedParameter($token) - $qb->createNamedParameter(time()) - $qb->createNamedParameter('') + $qb->createNamedParameter($this->supportedShareType, IQueryBuilder::PARAM_INT_ARRAY) $qb->createNamedParameter($this->supportedShareType, IQueryBuilder::PARAM_INT_ARRAY) $qb->createNamedParameter($this->supportedShareType, IQueryBuilder::PARAM_INT_ARRAY) @@ -1703,17 +1691,8 @@ - + $builder->createNamedParameter($groupIds, IQueryBuilder::PARAM_STR_ARRAY) - $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT) - $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR) - $builder->createNamedParameter($value, IQueryBuilder::PARAM_STR) - $builder->createNamedParameter($mountId, IQueryBuilder::PARAM_INT) - $builder->createNamedParameter($key, IQueryBuilder::PARAM_STR) - $builder->createNamedParameter(json_encode($value), IQueryBuilder::PARAM_STR) - $builder->createNamedParameter($mountId) - $builder->createNamedParameter($type) - $builder->createNamedParameter($value) null @@ -1755,10 +1734,9 @@ - + 'ExternalMountProvider' - 'OCP\Collaboration\Resources::loadAdditionalScripts' - 'OCP\Share::postShare' + '\OCP\Collaboration\Resources::loadAdditionalScripts' @@ -2073,15 +2051,6 @@ false - - $ma - - - $query->execute([$uid]) - - - bool - $timestamp $timestamp @@ -2135,11 +2104,6 @@ getURLGenerator - - - 'OC\AccountManager::userUpdated' - - $publicData[IAccountManager::PROPERTY_DISPLAYNAME]['value'] @@ -2217,8 +2181,9 @@ - + IDBConnection::CHECK_MISSING_INDEXES_EVENT + IDBConnection::CHECK_MISSING_PRIMARY_KEYS_EVENT IDBConnection::CHECK_MISSING_COLUMNS_EVENT @@ -2235,7 +2200,8 @@ 0 $lastCronRun - + + dispatch dispatch dispatch @@ -2308,21 +2274,7 @@ - - $qb->createNamedParameter(IShare::TYPE_EMAIL) - $qb->createNamedParameter($itemType) - $qb->createNamedParameter($itemSource) - $qb->createNamedParameter($itemSource) - $qb->createNamedParameter($shareWith) - $qb->createNamedParameter($uidOwner) - $qb->createNamedParameter($sharedBy) - $qb->createNamedParameter($permissions) - $qb->createNamedParameter($token) - $qb->createNamedParameter($password) - $qb->createNamedParameter($sendPasswordByTalk, IQueryBuilder::PARAM_BOOL) - $qb->createNamedParameter(time()) - $qb->createNamedParameter((int)$hideDownload, IQueryBuilder::PARAM_INT) - $qb->createNamedParameter('') + $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY) @@ -2485,19 +2437,11 @@ string[] - + [$attr => $result['values']] $key $key $e->getCode() - $nameAttribute - $filter - $this->connection->ldapLoginFilter - $this->connection->ldapLoginFilter - $this->connection->ldapUserDisplayName - $this->connection->ldapUserDisplayName - $this->connection->ldapGroupDisplayName - $filter $cookie @@ -2568,27 +2512,9 @@ bool - - $gAssoc - $this->access->connection->ldapLoginFilter - $this->access->connection->ldapDynamicGroupMemberURL - $this->access->connection->ldapGroupFilter - $this->access->connection->ldapGroupMemberAssocAttr - $this->access->connection->ldapGidNumber + $groupID $groupID - $this->access->connection->ldapDynamicGroupMemberURL - $this->access->connection->ldapGroupFilter - $this->access->connection->ldapUserDisplayName - $this->access->connection->ldapGroupMemberAssocAttr - [strtolower($this->access->connection->ldapGroupMemberAssocAttr), $this->access->connection->ldapGroupDisplayName, 'dn'] - $this->access->connection->ldapLoginFilter - $this->access->connection->ldapUserDisplayName - $this->access->connection->ldapLoginFilter - $this->access->connection->ldapUserDisplayName - [$this->access->connection->ldapGroupDisplayName, 'dn'] - $this->access->connection->ldapGroupFilter - $this->access->connection->ldapGroupDisplayName !is_array($members) || count($members) === 0 @@ -2724,10 +2650,6 @@ public function setLdapAccess(Access $access) { - - $homeRule - $homeRule - @@ -2740,34 +2662,18 @@ null null - - $this->connection->ldapQuotaAttribute - $this->connection->ldapUserDisplayName - $this->connection->ldapUserDisplayName2 - $this->connection->ldapEmailAttribute - $this->connection->homeFolderNamingRule - $this->connection->homeFolderNamingRule + $this->getHomePath($ldapEntry[$attr][0]) - $this->connection->ldapExtStorageHomeAttribute - $this->access->connection->homeFolderNamingRule - $this->access->connection->homeFolderNamingRule true 1 - $emailAttribute - $quotaAttribute - $this->connection->ldapExtStorageHomeAttribute string|false - - $this->access->connection->ldapUserFilter - $this->access->connection->ldapUserFilter + $path - $additionalAttribute - $this->access->connection->ldapUserDisplayName $limit $offset @@ -2979,7 +2885,7 @@ - broadcasttest + 'broadcasttest' @@ -3028,10 +2934,15 @@ dispatch + + + IDBConnection::ADD_MISSING_PRIMARY_KEYS_EVENT + + + dispatch + + - - $insertQuery->createParameter($key) - setFilterSchemaAssetsExpression @@ -3213,7 +3124,6 @@ $this $this - $this @@ -3498,11 +3408,6 @@ $default - - - $closure - - false @@ -3793,9 +3698,6 @@ - - $builder->createNamedParameter($value) - $builder->execute() @@ -3807,9 +3709,6 @@ $this->conn->fetchColumn('SELECT lastval()') - - $builder->createNamedParameter($value) - @@ -4034,8 +3933,7 @@ - - $builder->createNamedParameter($value) + $fun->md5($newPathFunction) $newPathFunction @@ -4091,9 +3989,6 @@ $filesData $data - - closeCursor - @@ -4108,7 +4003,7 @@ $builder->func()->greatest('mtime', $builder->createNamedParameter((int)$time, IQueryBuilder::PARAM_INT)) - $query->createFunction('GREATEST(' . $query->getColumnName('mtime') . ', ' . $query->createParameter('time') . ')') + $query->func()->greatest('mtime', $query->createParameter('time')) $sizeQuery->func()->add('size', $sizeQuery->createParameter('size')) @@ -4898,12 +4793,6 @@ true - - - $position - - - false @@ -5004,12 +4893,6 @@ - - $builder->createNamedParameter($gid) - $builder->createNamedParameter($gid) - $qb->createNamedParameter($uid) - $qb->createNamedParameter($gid) - $this->groupCache[$gid]['displayname'] @@ -5427,11 +5310,6 @@ $permsFunc - - - \OC_DB::executeAudited(self::updateByNameStmt(), [$mimetypeId, $this->folderMimeTypeId, $mimetypeId, '%.' . $extension]) - - \OC_APP @@ -5460,9 +5338,6 @@ - - $qb->createNamedParameter($value) - null @@ -5587,9 +5462,8 @@ - $query->createNamedParameter($parents, IQueryBuilder::PARAM_INT_ARRAY) - $query->createNamedParameter($changeParent, IQueryBuilder::PARAM_INT_ARRAY) - $query->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY) + $query->createNamedParameter($changeParent, IQueryBuilder::PARAM_INT_ARRAY) + $query->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY) @@ -5613,27 +5487,7 @@ - - $qb->createNamedParameter($share->getShareType()) - $qb->createNamedParameter($share->getSharedWith()) - $qb->createNamedParameter(IShare::STATUS_PENDING) - $qb->createNamedParameter($share->getExpirationDate(), 'datetime') - $qb->createNamedParameter($share->getSharedWith()) - $qb->createNamedParameter($share->getExpirationDate(), 'datetime') - $qb->createNamedParameter($share->getLabel()) - $qb->createNamedParameter($share->getToken()) - $qb->createNamedParameter($share->getPassword()) - $qb->createNamedParameter($share->getSendPasswordByTalk(), IQueryBuilder::PARAM_BOOL) - $qb->createNamedParameter($share->getExpirationDate(), 'datetime') - $qb->createNamedParameter($share->getParent()) - $qb->createParameter('itemType') - $qb->createNamedParameter($share->getNode()->getId()) - $qb->createNamedParameter($share->getNode()->getId()) - $qb->createNamedParameter($share->getPermissions()) - $qb->createNamedParameter($share->getSharedBy()) - $qb->createNamedParameter($share->getShareOwner()) - $qb->createNamedParameter($share->getTarget()) - $qb->createNamedParameter(time()) + $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY) $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY) $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY) @@ -5847,8 +5701,7 @@ string string - - \OC_User::getUser() + \OC_User::getUser() $appName $appName @@ -6211,11 +6064,6 @@ $column - - - $qb->createNamedParameter($value, $type) - - $this->data @@ -6247,14 +6095,6 @@ $this->resources - - - Closure - - - Closure - - $jobList From 388b3107eb57897d0b7910e1d9e4634797e74f4c Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 12 Nov 2020 15:03:21 +0100 Subject: [PATCH 18/19] fix migration of oc_credentials table Signed-off-by: Robin Appelman --- .../Version20000Date20201109081918.php | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/core/Migrations/Version20000Date20201109081918.php b/core/Migrations/Version20000Date20201109081918.php index cea71148bc1..49bbd79b67d 100644 --- a/core/Migrations/Version20000Date20201109081918.php +++ b/core/Migrations/Version20000Date20201109081918.php @@ -52,26 +52,28 @@ class Version20000Date20201109081918 extends SimpleMigrationStep { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); - $table = $schema->createTable('storages_credentials'); - $table->addColumn('id', Type::BIGINT, [ - 'autoincrement' => true, - 'notnull' => true, - 'length' => 64, - ]); - $table->addColumn('user', Type::STRING, [ - 'notnull' => false, - 'length' => 64, - ]); - $table->addColumn('identifier', Type::STRING, [ - 'notnull' => true, - 'length' => 64, - ]); - $table->addColumn('credentials', Type::TEXT, [ - 'notnull' => false, - ]); - $table->setPrimaryKey(['id']); - $table->addUniqueIndex(['user', 'identifier'], 'stocred_ui'); - $table->addIndex(['user'], 'stocred_user'); + if (!$schema->hasTable('storages_credentials')) { + $table = $schema->createTable('storages_credentials'); + $table->addColumn('id', Type::BIGINT, [ + 'autoincrement' => true, + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('user', Type::STRING, [ + 'notnull' => false, + 'length' => 64, + ]); + $table->addColumn('identifier', Type::STRING, [ + 'notnull' => true, + 'length' => 64, + ]); + $table->addColumn('credentials', Type::TEXT, [ + 'notnull' => false, + ]); + $table->setPrimaryKey(['id']); + $table->addUniqueIndex(['user', 'identifier'], 'stocred_ui'); + $table->addIndex(['user'], 'stocred_user'); + } return $schema; } @@ -92,9 +94,9 @@ class Version20000Date20201109081918 extends SimpleMigrationStep { $insert = $this->connection->getQueryBuilder(); $insert->insert('storages_credentials') - ->setValue('user', $insert->createNamedParameter('user')) - ->setValue('identifier', $insert->createNamedParameter('identifier')) - ->setValue('credentials', $insert->createNamedParameter('credentials')); + ->setValue('user', $insert->createParameter('user')) + ->setValue('identifier', $insert->createParameter('identifier')) + ->setValue('credentials', $insert->createParameter('credentials')); $result = $query->execute(); while ($row = $result->fetch()) { From 9497dca2b0eda4e0928bfaecd3e6afd38f81ac7b Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 12 Nov 2020 19:38:06 +0100 Subject: [PATCH 19/19] Update psalm-baseline Signed-off-by: Morris Jobke --- build/psalm-baseline.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index 56f398dee96..e5b0f0c77cb 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -4793,6 +4793,14 @@ true + + + $position + + + $cacheEntry + + false