From d76f429608f5a1648c695eeb7e9bb2cd43acdd9d Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Mon, 10 Jul 2017 13:09:11 +0000 Subject: [PATCH 01/16] Starting modifications in testing app to increase the fileID autoincremental number Added entry point to testing api Added behaviour to use fileids beyond 32 bits in tests Port is variable, we need to take that into account --- apps/testing/appinfo/routes.php | 13 ++++ apps/testing/lib/BigFileID.php | 60 +++++++++++++++++++ .../features/bootstrap/BasicStructure.php | 11 ++++ 3 files changed, 84 insertions(+) create mode 100644 apps/testing/lib/BigFileID.php diff --git a/apps/testing/appinfo/routes.php b/apps/testing/appinfo/routes.php index 031c225a06b6..c7cb91e85ce4 100644 --- a/apps/testing/appinfo/routes.php +++ b/apps/testing/appinfo/routes.php @@ -22,6 +22,7 @@ namespace OCA\Testing\AppInfo; use OCA\Testing\Config; +use OCA\Testing\BigFileID; use OCA\Testing\Locking\Provisioning; use OCP\API; @@ -59,3 +60,15 @@ API::register('delete', '/apps/testing/api/v1/lockprovisioning/{type}/{user}', [$locking, 'releaseLock'], 'files_lockprovisioning', API::ADMIN_AUTH); API::register('delete', '/apps/testing/api/v1/lockprovisioning/{type}', [$locking, 'releaseAll'], 'files_lockprovisioning', API::ADMIN_AUTH); API::register('delete', '/apps/testing/api/v1/lockprovisioning', [$locking, 'releaseAll'], 'files_lockprovisioning', API::ADMIN_AUTH); + +$bigFileID = new BigFileID( + \OC::$server->getDatabaseConnection() +); + +API::register( + 'post', + '/apps/testing/api/v1/increasefileid', + [$bigFileID, 'increaseFileIDsBeyondMax32bits'], + 'testing', + API::ADMIN_AUTH +); diff --git a/apps/testing/lib/BigFileID.php b/apps/testing/lib/BigFileID.php new file mode 100644 index 000000000000..b60a93d47dc2 --- /dev/null +++ b/apps/testing/lib/BigFileID.php @@ -0,0 +1,60 @@ + + * + * @copyright Copyright (c) 2017, ownCloud GmbH + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * 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, version 3, + * along with this program. If not, see + * + */ + +namespace OCA\Testing; + +use OCP\IDBConnection; + +/** + * Class for increasing file ids over 32 bits max int + */ +class BigFileID { + + /** @var IDBConnection */ + private $connection; + + public function __construct(IDBConnection $connection) { + $this->connection = $connection; + } + + /** + * Put a dummy entry to make the autoincrement go beyond the 32 bits limit + * @return \OC_OCS_Result + */ + public function increaseFileIDsBeyondMax32bits(){ + \OC::$server->getLogger()->warning('Inserting dummy entry with fileid bigger than max int of 32 bits for testing'); + $insertedFileID = "'2147483647'"; + $queryCheckFileID = "SELECT * from oc_filecache where fileid=" . $insertedFileID; + $response = $this->connection->executeQuery($queryCheckFileID)->fetchAll(); + + if (empty($response)) { + $query = "INSERT INTO oc_filecache (fileid, storage, path, path_hash, parent, + name, mimetype, mimepart, size, mtime, storage_mtime, + encrypted, unencrypted_size, etag, permissions, checksum) + VALUES (" . $insertedFileID . ", '10000', 'dummy', '59f91d3e7ebd97ade2e147d2066cc4eb', '5831', + '', '4', '3', '163', '1499256550', '1499256550', + '0', '0', '595cd6e63f375', '27', 'NULL')"; + $this->connection->executeQuery($query); + } + return new \OC_OCS_Result(); + } + +} diff --git a/tests/integration/features/bootstrap/BasicStructure.php b/tests/integration/features/bootstrap/BasicStructure.php index 42e1936a5a74..9d4d0a031c5d 100644 --- a/tests/integration/features/bootstrap/BasicStructure.php +++ b/tests/integration/features/bootstrap/BasicStructure.php @@ -398,5 +398,16 @@ public static function removeFilesFromLocalStorageAfter(){ $file->isDir() ? rmdir($file) : unlink($file); } } + + /** + * @BeforeSuite + */ + public static function useBigFileIDs(){ + $fullUrl = getenv('TEST_SERVER_URL') . "/v1.php/apps/testing/api/v1/increasefileid"; + $client = new Client(); + $options = []; + $options['auth'] = ['admin','admin']; + $response = $client->send($client->createRequest('post', $fullUrl, $options)); + } } From edc623f67e5d8f6b77f668e08a14e9871d3b138b Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Fri, 14 Jul 2017 18:21:33 +0300 Subject: [PATCH 02/16] Alter some critical fields to BigInt --- .../Migrations/Version20170711193427.php | 32 +++++++++++++++++++ .../federatedfilesharing/appinfo/database.xml | 4 +-- apps/files_sharing/appinfo/database.xml | 4 +-- apps/files_trashbin/appinfo/database.xml | 2 +- core/Migrations/Version20170711191432.php | 26 +++++++++++++++ db_structure.xml | 7 ++-- 6 files changed, 67 insertions(+), 8 deletions(-) create mode 100644 apps/dav/appinfo/Migrations/Version20170711193427.php create mode 100644 core/Migrations/Version20170711191432.php diff --git a/apps/dav/appinfo/Migrations/Version20170711193427.php b/apps/dav/appinfo/Migrations/Version20170711193427.php new file mode 100644 index 000000000000..4ecfee1becd8 --- /dev/null +++ b/apps/dav/appinfo/Migrations/Version20170711193427.php @@ -0,0 +1,32 @@ +hasTable("${prefix}properties")) { + $table = $schema->getTable("{$prefix}properties"); + + $idColumn = $table->getColumn('id'); + if ($idColumn){ + $idColumn->setType(Type::getType(Type::BIGINT)); + $idColumn->setOptions(['length' => 20]); + } + + $fileidColumn = $table->getColumn('fileid'); + if ($fileidColumn){ + $fileidColumn->setType(Type::getType(Type::BIGINT)); + $fileidColumn->setOptions(['length' => 20]); + } + } + } +} diff --git a/apps/federatedfilesharing/appinfo/database.xml b/apps/federatedfilesharing/appinfo/database.xml index 1dbe8ee2ec90..c32d0d989733 100644 --- a/apps/federatedfilesharing/appinfo/database.xml +++ b/apps/federatedfilesharing/appinfo/database.xml @@ -19,13 +19,13 @@ the servers (e.g. permissions change, unshare,...) share_id integer true - 4 + 10 remote_id integer true - 4 + 10 share ID at the remote server diff --git a/apps/files_sharing/appinfo/database.xml b/apps/files_sharing/appinfo/database.xml index a70be408da4f..67cffe3705c4 100644 --- a/apps/files_sharing/appinfo/database.xml +++ b/apps/files_sharing/appinfo/database.xml @@ -13,7 +13,7 @@ 0 true 1 - 4 + 10 remote @@ -27,7 +27,7 @@ integer -1 true - 4 + 10 share_token diff --git a/apps/files_trashbin/appinfo/database.xml b/apps/files_trashbin/appinfo/database.xml index 2944a31b02d0..f13f6342545b 100644 --- a/apps/files_trashbin/appinfo/database.xml +++ b/apps/files_trashbin/appinfo/database.xml @@ -19,7 +19,7 @@ 0 true 1 - 4 + 10 diff --git a/core/Migrations/Version20170711191432.php b/core/Migrations/Version20170711191432.php new file mode 100644 index 000000000000..5ab681cd9d7c --- /dev/null +++ b/core/Migrations/Version20170711191432.php @@ -0,0 +1,26 @@ +hasTable("${prefix}share")) { + $table = $schema->getTable("{$prefix}share"); + + $fileSourceColumn = $table->getColumn('file_source'); + if ($fileSourceColumn){ + $fileSourceColumn->setType(Type::getType(Type::BIGINT)); + $fileSourceColumn->setOptions(['length' => 20]); + } + } + } +} diff --git a/db_structure.xml b/db_structure.xml index 2c35985e760d..3043561f040b 100644 --- a/db_structure.xml +++ b/db_structure.xml @@ -153,6 +153,7 @@ root_id integer + 10 true @@ -278,7 +279,7 @@ 0 true 1 - 4 + 10 @@ -312,7 +313,7 @@ integer true - 4 + 10 @@ -984,7 +985,7 @@ 0 true true - 4 + 10 From d8a73198b588ef938d9aaa9ea13ec2cbaec4fc51 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Fri, 14 Jul 2017 18:23:26 +0300 Subject: [PATCH 03/16] Fix 2 issues with postgres introduced by doctrine/dbal --- lib/private/DB/ConnectionFactory.php | 4 ++ lib/private/DB/OCPostgreSqlPlatform.php | 86 +++++++++++++++++++++++ tests/lib/DB/OCPostgreSqlPlatformTest.php | 74 +++++++++++++++++++ 3 files changed, 164 insertions(+) create mode 100644 lib/private/DB/OCPostgreSqlPlatform.php create mode 100644 tests/lib/DB/OCPostgreSqlPlatformTest.php diff --git a/lib/private/DB/ConnectionFactory.php b/lib/private/DB/ConnectionFactory.php index d592d427f0e4..91fc6ec598b9 100644 --- a/lib/private/DB/ConnectionFactory.php +++ b/lib/private/DB/ConnectionFactory.php @@ -129,6 +129,10 @@ public function getConnection($type, $additionalConnectionParams) { $additionalConnectionParams['platform'] = new OCSqlitePlatform(); $eventManager->addEventSubscriber(new SQLiteSessionInit(true, $journalMode)); break; + case 'pgsql': + case 'postgresql': + $additionalConnectionParams['platform'] = new OCPostgreSqlPlatform(); + break; } /** @var Connection $connection */ $connection = DriverManager::getConnection( diff --git a/lib/private/DB/OCPostgreSqlPlatform.php b/lib/private/DB/OCPostgreSqlPlatform.php new file mode 100644 index 000000000000..44ca929402e6 --- /dev/null +++ b/lib/private/DB/OCPostgreSqlPlatform.php @@ -0,0 +1,86 @@ + + * + * @copyright Copyright (c) 2017, ownCloud GmbH + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * 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, version 3, + * along with this program. If not, see + * + */ + +namespace OC\DB; + +use Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\Types\Type; + +class OCPostgreSqlPlatform extends \Doctrine\DBAL\Platforms\PostgreSqlPlatform { + + /** + * {@inheritDoc} + */ + public function getAlterTableSQL(TableDiff $diff){ + $sqls = parent::getAlterTableSQL($diff); + foreach ($sqls as $index => $sql){ + // BIGSERIAL could not be used in statements altering column type + // That's why we replace it with BIGINT + // see https://github.com/owncloud/core/pull/28364#issuecomment-315006853 + if (preg_match('|(ALTER TABLE\s+\S+\s+ALTER\s+\S+\s+TYPE\s+)(BIGSERIAL)|i', $sql, $matches)){ + $alterTable = $matches[1]; + $sqls[$index] = $alterTable . 'BIGINT'; + } + // Changing integer to bigint kills next autoincrement value + // see https://github.com/owncloud/core/pull/28364#issuecomment-315006853 + if (preg_match('|ALTER TABLE\s+(\S+)\s+ALTER\s+(\S+)\s+DROP DEFAULT|i', $sql, $matches)){ + $queryTableName = $matches[1]; + $queryColumnName = $matches[2]; + $columnDiff = $this->findColumnDiffByName($diff, $queryColumnName); + if ($columnDiff){ + if ($this->shouldSkipDropDefault($columnDiff)){ + unset($sqls[$index]); + continue; + } + } + } + } + + return $sqls; + } + + /** + * We should NOT drop next seqence value if + * - type was changed from INTEGER to BIGINT + * - column keeps an autoincrement + * - default value is kept NULL + */ + private function shouldSkipDropDefault($columnDiff){ + $column = $columnDiff->column; + $fromColumn = $columnDiff->fromColumn; + return $fromColumn->getType()->getName() === Type::INTEGER + && $column->getType()->getName() === Type::BIGINT + && is_null($fromColumn->getDefault()) + && is_null($column->getDefault()) + && $fromColumn->getAutoincrement() + && $column->getAutoincrement(); + } + + private function findColumnDiffByName($diff, $name){ + foreach ($diff->changedColumns as $columnDiff){ + $oldColumnName = $columnDiff->getOldColumnName()->getQuotedName($this); + if ($oldColumnName === $name){ + return $columnDiff; + } + return false; + } + } +} diff --git a/tests/lib/DB/OCPostgreSqlPlatformTest.php b/tests/lib/DB/OCPostgreSqlPlatformTest.php new file mode 100644 index 000000000000..56fab621cfc4 --- /dev/null +++ b/tests/lib/DB/OCPostgreSqlPlatformTest.php @@ -0,0 +1,74 @@ + + * + * @copyright Copyright (c) 2017, ownCloud GmbH + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * 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, version 3, + * along with this program. If not, see + * + */ + +namespace Test\DB; + +use Doctrine\DBAL\Schema\Comparator; +use Doctrine\DBAL\Schema\Schema; +use Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\Types\Type; +use OC\DB\OCPostgreSqlPlatform; + + /** + * Class OCPostgreSqlPlatformTest + * + * @group DB + * + * @package Test\DB + */ + +class OCPostgreSqlPlatformTest extends \Test\TestCase { + + public function testAlterBigint(){ + $platform = new OCPostgreSqlPlatform(); + $sourceSchema = new Schema(); + $targetSchema = new Schema(); + + $this->createTableAndColumn($sourceSchema, Type::INTEGER); + $this->createTableAndColumn($targetSchema, Type::BIGINT); + + $comparator = new Comparator(); + $diff = $comparator->compare($sourceSchema, $targetSchema); + $sqlStatements = $diff->toSql($platform); + $this->assertContains( + 'ALTER TABLE poor_yorick ALTER id TYPE BIGINT', + $sqlStatements, + true + ); + + $this->assertNotContains( + 'ALTER TABLE poor_yorick ALTER id DROP DEFAULT', + $sqlStatements, + true + ); + } + + protected function createTableAndColumn($schema, $type){ + $table = $schema->createTable("poor_yorick"); + $table->addColumn('id', $type, [ + 'autoincrement' => true, + 'unsigned' => true, + 'notnull' => true, + 'length' => 11, + ]); + } + +} From 07fcb3f67e0572912370d21e6d0242d4e428a0de Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Mon, 31 Jul 2017 20:03:53 +0300 Subject: [PATCH 04/16] Postreview changes --- lib/private/DB/ConnectionFactory.php | 1 - lib/private/DB/OCPostgreSqlPlatform.php | 41 +++++++++++++++---------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/lib/private/DB/ConnectionFactory.php b/lib/private/DB/ConnectionFactory.php index 91fc6ec598b9..ef98ff570169 100644 --- a/lib/private/DB/ConnectionFactory.php +++ b/lib/private/DB/ConnectionFactory.php @@ -130,7 +130,6 @@ public function getConnection($type, $additionalConnectionParams) { $eventManager->addEventSubscriber(new SQLiteSessionInit(true, $journalMode)); break; case 'pgsql': - case 'postgresql': $additionalConnectionParams['platform'] = new OCPostgreSqlPlatform(); break; } diff --git a/lib/private/DB/OCPostgreSqlPlatform.php b/lib/private/DB/OCPostgreSqlPlatform.php index 44ca929402e6..53a5e49c8536 100644 --- a/lib/private/DB/OCPostgreSqlPlatform.php +++ b/lib/private/DB/OCPostgreSqlPlatform.php @@ -21,49 +21,53 @@ namespace OC\DB; +use Doctrine\DBAL\Platforms\PostgreSqlPlatform; +use Doctrine\DBAL\Schema\ColumnDiff; use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Types\Type; -class OCPostgreSqlPlatform extends \Doctrine\DBAL\Platforms\PostgreSqlPlatform { +class OCPostgreSqlPlatform extends PostgreSqlPlatform { - /** - * {@inheritDoc} - */ + /** + * {@inheritDoc} + */ public function getAlterTableSQL(TableDiff $diff){ - $sqls = parent::getAlterTableSQL($diff); - foreach ($sqls as $index => $sql){ + $queries = parent::getAlterTableSQL($diff); + foreach ($queries as $index => $sql){ // BIGSERIAL could not be used in statements altering column type // That's why we replace it with BIGINT // see https://github.com/owncloud/core/pull/28364#issuecomment-315006853 if (preg_match('|(ALTER TABLE\s+\S+\s+ALTER\s+\S+\s+TYPE\s+)(BIGSERIAL)|i', $sql, $matches)){ $alterTable = $matches[1]; - $sqls[$index] = $alterTable . 'BIGINT'; + $queries[$index] = $alterTable . 'BIGINT'; } // Changing integer to bigint kills next autoincrement value // see https://github.com/owncloud/core/pull/28364#issuecomment-315006853 if (preg_match('|ALTER TABLE\s+(\S+)\s+ALTER\s+(\S+)\s+DROP DEFAULT|i', $sql, $matches)){ - $queryTableName = $matches[1]; $queryColumnName = $matches[2]; $columnDiff = $this->findColumnDiffByName($diff, $queryColumnName); if ($columnDiff){ if ($this->shouldSkipDropDefault($columnDiff)){ - unset($sqls[$index]); + unset($queries[$index]); continue; } } } } - return $sqls; + return $queries; } - + /** - * We should NOT drop next seqence value if + * We should NOT drop next sequence value if * - type was changed from INTEGER to BIGINT * - column keeps an autoincrement * - default value is kept NULL + * + * @param ColumnDiff $columnDiff + * @return bool */ - private function shouldSkipDropDefault($columnDiff){ + private function shouldSkipDropDefault(ColumnDiff $columnDiff){ $column = $columnDiff->column; $fromColumn = $columnDiff->fromColumn; return $fromColumn->getType()->getName() === Type::INTEGER @@ -73,14 +77,19 @@ private function shouldSkipDropDefault($columnDiff){ && $fromColumn->getAutoincrement() && $column->getAutoincrement(); } - - private function findColumnDiffByName($diff, $name){ + + /** + * @param TableDiff $diff + * @param string $name + * @return ColumnDiff | false + */ + private function findColumnDiffByName(TableDiff $diff, $name){ foreach ($diff->changedColumns as $columnDiff){ $oldColumnName = $columnDiff->getOldColumnName()->getQuotedName($this); if ($oldColumnName === $name){ return $columnDiff; } - return false; } + return false; } } From 761b5b22a123470f8b6c377ff52d55d152b3ae99 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Fri, 4 Aug 2017 21:30:48 +0300 Subject: [PATCH 05/16] Update federatedreshares to bigint --- .../Migrations/Version20170804201125.php | 22 ++++++++++++++ .../Migrations/Version20170804201253.php | 30 +++++++++++++++++++ apps/federatedfilesharing/appinfo/info.xml | 1 + 3 files changed, 53 insertions(+) create mode 100644 apps/federatedfilesharing/appinfo/Migrations/Version20170804201125.php create mode 100644 apps/federatedfilesharing/appinfo/Migrations/Version20170804201253.php diff --git a/apps/federatedfilesharing/appinfo/Migrations/Version20170804201125.php b/apps/federatedfilesharing/appinfo/Migrations/Version20170804201125.php new file mode 100644 index 000000000000..8f66af108d1f --- /dev/null +++ b/apps/federatedfilesharing/appinfo/Migrations/Version20170804201125.php @@ -0,0 +1,22 @@ +hasTable("{$prefix}federated_reshares")) { + return; + } + // not that valid .... + $schemaReader = new MDB2SchemaReader( + \OC::$server->getConfig(), + \OC::$server->getDatabaseConnection()->getDatabasePlatform() + ); + $schemaReader->loadSchemaFromFile(__DIR__ . '/../database.xml', $schema); + } +} diff --git a/apps/federatedfilesharing/appinfo/Migrations/Version20170804201253.php b/apps/federatedfilesharing/appinfo/Migrations/Version20170804201253.php new file mode 100644 index 000000000000..f33683f05331 --- /dev/null +++ b/apps/federatedfilesharing/appinfo/Migrations/Version20170804201253.php @@ -0,0 +1,30 @@ +hasTable("${prefix}federated_reshares")) { + $table = $schema->getTable("{$prefix}federated_reshares"); + + $shareIdColumn = $table->getColumn('share_id'); + if ($shareIdColumn && $shareIdColumn->getType()->getName() !== Type::BIGINT) { + $shareIdColumn->setType(Type::getType(Type::BIGINT)); + $shareIdColumn->setOptions(['length' => 20]); + } + + $remoteIdColumn = $table->getColumn('remote_id'); + if ($remoteIdColumn && $remoteIdColumn->getType()->getName() !== Type::BIGINT) { + $remoteIdColumn->setType(Type::getType(Type::BIGINT)); + $remoteIdColumn->setOptions(['length' => 20]); + } + } + } +} diff --git a/apps/federatedfilesharing/appinfo/info.xml b/apps/federatedfilesharing/appinfo/info.xml index 5c2cb0bdf235..1507d3b4198c 100644 --- a/apps/federatedfilesharing/appinfo/info.xml +++ b/apps/federatedfilesharing/appinfo/info.xml @@ -7,6 +7,7 @@ Bjoern Schiessle, Roeland Jago Douma 0.3.0 FederatedFileSharing + true other From b51e83f493433f857a4cb1117909b3a6ec782c7f Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Fri, 4 Aug 2017 21:32:00 +0300 Subject: [PATCH 06/16] Bump federatedfilesharing to 0.3.1 to trigger migrations --- apps/federatedfilesharing/appinfo/info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/federatedfilesharing/appinfo/info.xml b/apps/federatedfilesharing/appinfo/info.xml index 1507d3b4198c..39c51da2e9ce 100644 --- a/apps/federatedfilesharing/appinfo/info.xml +++ b/apps/federatedfilesharing/appinfo/info.xml @@ -5,7 +5,7 @@ Provide federated file sharing across ownCloud servers AGPL Bjoern Schiessle, Roeland Jago Douma - 0.3.0 + 0.3.1 FederatedFileSharing true other From 757bf412b32a26eef664ae499dbb64bb81f4eb81 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Fri, 4 Aug 2017 21:40:32 +0300 Subject: [PATCH 07/16] Update files_sharing to bigint --- .../Migrations/Version20170804201125.php | 22 ++++++++++++++ .../Migrations/Version20170804201253.php | 30 +++++++++++++++++++ apps/files_sharing/appinfo/info.xml | 1 + 3 files changed, 53 insertions(+) create mode 100644 apps/files_sharing/appinfo/Migrations/Version20170804201125.php create mode 100644 apps/files_sharing/appinfo/Migrations/Version20170804201253.php diff --git a/apps/files_sharing/appinfo/Migrations/Version20170804201125.php b/apps/files_sharing/appinfo/Migrations/Version20170804201125.php new file mode 100644 index 000000000000..3ce2969203ef --- /dev/null +++ b/apps/files_sharing/appinfo/Migrations/Version20170804201125.php @@ -0,0 +1,22 @@ +hasTable("{$prefix}share_external")) { + return; + } + // not that valid .... + $schemaReader = new MDB2SchemaReader( + \OC::$server->getConfig(), + \OC::$server->getDatabaseConnection()->getDatabasePlatform() + ); + $schemaReader->loadSchemaFromFile(__DIR__ . '/../database.xml', $schema); + } +} diff --git a/apps/files_sharing/appinfo/Migrations/Version20170804201253.php b/apps/files_sharing/appinfo/Migrations/Version20170804201253.php new file mode 100644 index 000000000000..a890982bc042 --- /dev/null +++ b/apps/files_sharing/appinfo/Migrations/Version20170804201253.php @@ -0,0 +1,30 @@ +hasTable("${prefix}share_external")) { + $table = $schema->getTable("{$prefix}share_external"); + + $idColumn = $table->getColumn('id'); + if ($idColumn && $idColumn->getType()->getName() !== Type::BIGINT) { + $idColumn->setType(Type::getType(Type::BIGINT)); + $idColumn->setOptions(['length' => 20]); + } + + $remoteIdColumn = $table->getColumn('remote_id'); + if ($remoteIdColumn && $remoteIdColumn->getType()->getName() !== Type::BIGINT) { + $remoteIdColumn->setType(Type::getType(Type::BIGINT)); + $remoteIdColumn->setOptions(['length' => 20]); + } + } + } +} diff --git a/apps/files_sharing/appinfo/info.xml b/apps/files_sharing/appinfo/info.xml index 1abc22d38ab9..e5d42ca715f4 100644 --- a/apps/files_sharing/appinfo/info.xml +++ b/apps/files_sharing/appinfo/info.xml @@ -14,6 +14,7 @@ Turning the feature off removes shared files and folders on the server for all s + true From e1a52cce60767528f858dcb997617e8cf6ac527b Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Fri, 4 Aug 2017 21:42:02 +0300 Subject: [PATCH 08/16] Bump files_sharing to 0.10.1 to trigger migrations --- apps/files_sharing/appinfo/info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_sharing/appinfo/info.xml b/apps/files_sharing/appinfo/info.xml index e5d42ca715f4..a7f3380e09b3 100644 --- a/apps/files_sharing/appinfo/info.xml +++ b/apps/files_sharing/appinfo/info.xml @@ -10,7 +10,7 @@ Turning the feature off removes shared files and folders on the server for all s AGPL Michael Gapczynski, Bjoern Schiessle - 0.10.0 + 0.10.1 From fad9b2845e5c4fa0df3c4abfd940eb039d3b559f Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Fri, 4 Aug 2017 21:53:40 +0300 Subject: [PATCH 09/16] Update files_trashbin to bigint --- .../Migrations/Version20170804201125.php | 22 +++++++++++++++++ .../Migrations/Version20170804201253.php | 24 +++++++++++++++++++ apps/files_trashbin/appinfo/info.xml | 1 + 3 files changed, 47 insertions(+) create mode 100644 apps/files_trashbin/appinfo/Migrations/Version20170804201125.php create mode 100644 apps/files_trashbin/appinfo/Migrations/Version20170804201253.php diff --git a/apps/files_trashbin/appinfo/Migrations/Version20170804201125.php b/apps/files_trashbin/appinfo/Migrations/Version20170804201125.php new file mode 100644 index 000000000000..9a650abddec8 --- /dev/null +++ b/apps/files_trashbin/appinfo/Migrations/Version20170804201125.php @@ -0,0 +1,22 @@ +hasTable("{$prefix}files_trash")) { + return; + } + // not that valid .... + $schemaReader = new MDB2SchemaReader( + \OC::$server->getConfig(), + \OC::$server->getDatabaseConnection()->getDatabasePlatform() + ); + $schemaReader->loadSchemaFromFile(__DIR__ . '/../database.xml', $schema); + } +} diff --git a/apps/files_trashbin/appinfo/Migrations/Version20170804201253.php b/apps/files_trashbin/appinfo/Migrations/Version20170804201253.php new file mode 100644 index 000000000000..6d8ef41f970a --- /dev/null +++ b/apps/files_trashbin/appinfo/Migrations/Version20170804201253.php @@ -0,0 +1,24 @@ +hasTable("${prefix}files_trash")) { + $table = $schema->getTable("{$prefix}files_trash"); + + $idColumn = $table->getColumn('auto_id'); + if ($idColumn && $idColumn->getType()->getName() !== Type::BIGINT) { + $idColumn->setType(Type::getType(Type::BIGINT)); + $idColumn->setOptions(['length' => 20]); + } + } + } +} diff --git a/apps/files_trashbin/appinfo/info.xml b/apps/files_trashbin/appinfo/info.xml index d5fa18d54acd..2848729a7fea 100644 --- a/apps/files_trashbin/appinfo/info.xml +++ b/apps/files_trashbin/appinfo/info.xml @@ -14,6 +14,7 @@ To prevent a user from running out of disk space, the ownCloud Deleted files app + true Files_Trashbin From 45d84d880687c544834ab71e422ec55e9ab54af7 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Fri, 4 Aug 2017 22:20:43 +0300 Subject: [PATCH 10/16] Bump files_trashbin to 0.9.1 to trigger migrations --- apps/files_trashbin/appinfo/info.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_trashbin/appinfo/info.xml b/apps/files_trashbin/appinfo/info.xml index 2848729a7fea..49bd945eda4f 100644 --- a/apps/files_trashbin/appinfo/info.xml +++ b/apps/files_trashbin/appinfo/info.xml @@ -10,7 +10,7 @@ To prevent a user from running out of disk space, the ownCloud Deleted files app AGPL Bjoern Schiessle - 0.9.0 + 0.9.1 From e2bf4c1f96e3ca5cf8e09187221cfe83f364e6fe Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Fri, 4 Aug 2017 22:24:53 +0300 Subject: [PATCH 11/16] Bump depends and core version --- apps/federatedfilesharing/appinfo/info.xml | 2 +- apps/files_sharing/appinfo/info.xml | 2 +- apps/files_trashbin/appinfo/info.xml | 2 +- version.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/federatedfilesharing/appinfo/info.xml b/apps/federatedfilesharing/appinfo/info.xml index 39c51da2e9ce..db92e77c0294 100644 --- a/apps/federatedfilesharing/appinfo/info.xml +++ b/apps/federatedfilesharing/appinfo/info.xml @@ -10,7 +10,7 @@ true other - + OCA\FederatedFileSharing\AdminPanel diff --git a/apps/files_sharing/appinfo/info.xml b/apps/files_sharing/appinfo/info.xml index a7f3380e09b3..6ce538d22bf7 100644 --- a/apps/files_sharing/appinfo/info.xml +++ b/apps/files_sharing/appinfo/info.xml @@ -16,7 +16,7 @@ Turning the feature off removes shared files and folders on the server for all s true - + public.php diff --git a/apps/files_trashbin/appinfo/info.xml b/apps/files_trashbin/appinfo/info.xml index 49bd945eda4f..17bfe4db3591 100644 --- a/apps/files_trashbin/appinfo/info.xml +++ b/apps/files_trashbin/appinfo/info.xml @@ -17,7 +17,7 @@ To prevent a user from running out of disk space, the ownCloud Deleted files app true Files_Trashbin - + user-trashbin diff --git a/version.php b/version.php index 66f94445ccb7..377f5203e537 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ // We only can count up. The 4. digit is only for the internal patchlevel to trigger DB upgrades // between betas, final and RCs. This is _not_ the public version number. Reset minor/patchlevel // when updating major/minor version number. -$OC_Version = [10, 0, 2, 3]; +$OC_Version = [10, 0, 2, 4]; // The human readable string $OC_VersionString = '10.0.2'; From adf55ff56c98f337e526f71971dfafbefff00754 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Fri, 4 Aug 2017 22:36:59 +0300 Subject: [PATCH 12/16] Update core tables to bigint --- core/Migrations/Version20170804201253.php | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 core/Migrations/Version20170804201253.php diff --git a/core/Migrations/Version20170804201253.php b/core/Migrations/Version20170804201253.php new file mode 100644 index 000000000000..2bb62f49a574 --- /dev/null +++ b/core/Migrations/Version20170804201253.php @@ -0,0 +1,37 @@ +updateToBigint($schema, "${prefix}mounts", "root_id"); + $this->updateToBigint($schema, "${prefix}filecache", "fileid"); + $this->updateToBigint($schema, "${prefix}filecache", "parent"); + $this->updateToBigint($schema, "${prefix}vcategory_to_object", "objid"); + } + + /** + * @param Schema $schema + * @param string $tableName + * @param string $columnName + */ + protected function updateToBigint(Schema $schema, $tableName, $columnName) { + if ($schema->hasTable($tableName)) { + $table = $schema->getTable($tableName); + + $column = $table->getColumn($columnName); + if ($column && $column->getType()->getName() !== Type::BIGINT) { + $column->setType(Type::getType(Type::BIGINT)); + $column->setOptions(['length' => 20]); + } + } + } +} From f5b1f6837d2ad36a195e1581854c8fd9b7b0a0d0 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Mon, 7 Aug 2017 17:15:35 +0300 Subject: [PATCH 13/16] Port tables to migration --- .../Migrations/Version20170804201125.php | 28 +++-- .../federatedfilesharing/appinfo/database.xml | 41 ------- .../Migrations/Version20170804201125.php | 90 +++++++++++++-- apps/files_sharing/appinfo/database.xml | 109 ------------------ .../Migrations/Version20170804201125.php | 67 +++++++++-- apps/files_trashbin/appinfo/database.xml | 101 ---------------- 6 files changed, 158 insertions(+), 278 deletions(-) delete mode 100644 apps/federatedfilesharing/appinfo/database.xml delete mode 100644 apps/files_sharing/appinfo/database.xml delete mode 100644 apps/files_trashbin/appinfo/database.xml diff --git a/apps/federatedfilesharing/appinfo/Migrations/Version20170804201125.php b/apps/federatedfilesharing/appinfo/Migrations/Version20170804201125.php index 8f66af108d1f..ce30e2fc4e76 100644 --- a/apps/federatedfilesharing/appinfo/Migrations/Version20170804201125.php +++ b/apps/federatedfilesharing/appinfo/Migrations/Version20170804201125.php @@ -2,21 +2,31 @@ namespace OCA\FederatedFileSharing\Migrations; use Doctrine\DBAL\Schema\Schema; -use OC\DB\MDB2SchemaReader; use OCP\Migration\ISchemaMigration; /** Creates initial schema */ class Version20170804201125 implements ISchemaMigration { public function changeSchema(Schema $schema, array $options) { $prefix = $options['tablePrefix']; - if ($schema->hasTable("{$prefix}federated_reshares")) { - return; + if (!$schema->hasTable("{$prefix}federated_reshares")) { + $table = $schema->createTable("{$prefix}federated_reshares"); + $table->addColumn('share_id', 'bigint', [ + 'unsigned' => false, + 'notnull' => true, + 'length' => 11, + ]); + + $table->addColumn('remote_id', 'bigint', [ + 'unsigned' => false, + 'notnull' => true, + 'length' => 11, + 'comment' => 'share ID at the remote server' + ]); + + $table->addUniqueIndex( + ['share_id'], + 'share_id_index' + ); } - // not that valid .... - $schemaReader = new MDB2SchemaReader( - \OC::$server->getConfig(), - \OC::$server->getDatabaseConnection()->getDatabasePlatform() - ); - $schemaReader->loadSchemaFromFile(__DIR__ . '/../database.xml', $schema); } } diff --git a/apps/federatedfilesharing/appinfo/database.xml b/apps/federatedfilesharing/appinfo/database.xml deleted file mode 100644 index c32d0d989733..000000000000 --- a/apps/federatedfilesharing/appinfo/database.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - *dbname* - true - false - utf8 - - *dbprefix*federated_reshares - - - share_id - integer - true - 10 - - - remote_id - integer - true - 10 - share ID at the remote server - - - share_id_index - true - - share_id - ascending - - - -
-
diff --git a/apps/files_sharing/appinfo/Migrations/Version20170804201125.php b/apps/files_sharing/appinfo/Migrations/Version20170804201125.php index 3ce2969203ef..e0b38b478ab5 100644 --- a/apps/files_sharing/appinfo/Migrations/Version20170804201125.php +++ b/apps/files_sharing/appinfo/Migrations/Version20170804201125.php @@ -2,21 +2,93 @@ namespace OCA\Files_Sharing\Migrations; use Doctrine\DBAL\Schema\Schema; -use OC\DB\MDB2SchemaReader; use OCP\Migration\ISchemaMigration; /** Creates initial schema */ class Version20170804201125 implements ISchemaMigration { public function changeSchema(Schema $schema, array $options) { $prefix = $options['tablePrefix']; - if ($schema->hasTable("{$prefix}share_external")) { - return; + if (!$schema->hasTable("{$prefix}share_external")) { + $table = $schema->createTable("{$prefix}share_external"); + $table->addColumn('id', 'bigint', [ + 'autoincrement' => true, + 'unsigned' => false, + 'notnull' => true, + 'length' => 11, + ]); + + $table->addColumn('remote', 'string', [ + 'notnull' => true, + 'length' => 512, + 'default' => '', + 'comment' => 'Url of the remote owncloud instance' + ]); + + $table->addColumn('remote_id', 'bigint', [ + 'unsigned' => false, + 'notnull' => true, + 'default' => -1, + 'length' => 11, + ]); + + $table->addColumn('share_token', 'string', [ + 'length' => 64, + 'notnull' => true, + 'comment' => 'Public share token' + ]); + + $table->addColumn('password', 'string', [ + 'length' => 64, + 'notnull' => false, + 'default' => '', + 'comment' => 'Optional password for the public share' + ]); + + $table->addColumn('name', 'string', [ + 'length' => 64, + 'notnull' => true, + 'comment' => 'Original name on the remote server' + ]); + + $table->addColumn('owner', 'string', [ + 'length' => 64, + 'notnull' => true, + 'comment' => 'User that owns the public share on the remote server' + ]); + + $table->addColumn('user', 'string', [ + 'length' => 64, + 'notnull' => true, + 'comment' => 'Local user which added the external share' + ]); + + $table->addColumn('mountpoint', 'string', [ + 'length' => 4000, + 'notnull' => true, + 'comment' => 'Full path where the share is mounted' + ]); + + $table->addColumn('mountpoint_hash', 'string', [ + 'length' => 32, + 'notnull' => true, + 'comment' => 'md5 hash of the mountpoint' + ]); + + $table->addColumn('accepted', 'integer', [ + 'notnull' => true, + 'default' => 0, + ]); + + $table->setPrimaryKey(['id']); + + $table->addIndex( + ['user'], + 'sh_external_user' + ); + $table->addUniqueIndex( + ['user', 'mountpoint_hash'], + 'sh_external_mp' + ); } - // not that valid .... - $schemaReader = new MDB2SchemaReader( - \OC::$server->getConfig(), - \OC::$server->getDatabaseConnection()->getDatabasePlatform() - ); - $schemaReader->loadSchemaFromFile(__DIR__ . '/../database.xml', $schema); } } diff --git a/apps/files_sharing/appinfo/database.xml b/apps/files_sharing/appinfo/database.xml deleted file mode 100644 index 67cffe3705c4..000000000000 --- a/apps/files_sharing/appinfo/database.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - *dbname* - true - false - utf8 - - *dbprefix*share_external - - - id - integer - 0 - true - 1 - 10 - - - remote - text - true - 512 - Url of the remove owncloud instance - - - remote_id - integer - -1 - true - 10 - - - share_token - text - true - 64 - Public share token - - - password - text - false - 64 - Optional password for the public share - - - name - text - true - 64 - Original name on the remote server - - - owner - text - true - 64 - User that owns the public share on the remote server - - - user - text - true - 64 - Local user which added the external share - - - mountpoint - text - true - 4000 - Full path where the share is mounted - - - mountpoint_hash - text - true - 32 - md5 hash of the mountpoint - - - accepted - integer - 0 - true - 4 - - - sh_external_user - - user - ascending - - - - sh_external_mp - true - - user - ascending - - - mountpoint_hash - ascending - - - -
-
diff --git a/apps/files_trashbin/appinfo/Migrations/Version20170804201125.php b/apps/files_trashbin/appinfo/Migrations/Version20170804201125.php index 9a650abddec8..4777fe6b5b1b 100644 --- a/apps/files_trashbin/appinfo/Migrations/Version20170804201125.php +++ b/apps/files_trashbin/appinfo/Migrations/Version20170804201125.php @@ -2,21 +2,70 @@ namespace OCA\Files_Trashbin\Migrations; use Doctrine\DBAL\Schema\Schema; -use OC\DB\MDB2SchemaReader; use OCP\Migration\ISchemaMigration; /** Creates initial schema */ class Version20170804201125 implements ISchemaMigration { public function changeSchema(Schema $schema, array $options) { $prefix = $options['tablePrefix']; - if ($schema->hasTable("{$prefix}files_trash")) { - return; + if (!$schema->hasTable("{$prefix}files_trash")) { + $table = $schema->createTable("{$prefix}files_trash"); + $table->addColumn('auto_id', 'bigint', [ + 'autoincrement' => true, + 'unsigned' => false, + 'notnull' => true, + 'length' => 11, + ]); + + $table->addColumn('id', 'string', [ + 'length' => 250, + 'notnull' => true, + 'default' => '' + ]); + + $table->addColumn('user', 'string', [ + 'length' => 64, + 'notnull' => true, + 'default' => '' + ]); + + $table->addColumn('timestamp', 'string', [ + 'length' => 12, + 'notnull' => true, + 'default' => '' + ]); + + $table->addColumn('location', 'string', [ + 'length' => 512, + 'notnull' => true, + 'default' => '' + ]); + + $table->addColumn('type', 'string', [ + 'length' => 4, + 'notnull' => false, + 'default' => '' + ]); + + $table->addColumn('mime', 'string', [ + 'length' => 255, + 'notnull' => false, + 'default' => '' + ]); + + $table->setPrimaryKey(['auto_id']); + $table->addIndex( + ['id'], + 'id_index' + ); + $table->addIndex( + ['timestamp'], + 'timestamp_index' + ); + $table->addIndex( + ['user'], + 'user_index' + ); } - // not that valid .... - $schemaReader = new MDB2SchemaReader( - \OC::$server->getConfig(), - \OC::$server->getDatabaseConnection()->getDatabasePlatform() - ); - $schemaReader->loadSchemaFromFile(__DIR__ . '/../database.xml', $schema); } } diff --git a/apps/files_trashbin/appinfo/database.xml b/apps/files_trashbin/appinfo/database.xml deleted file mode 100644 index f13f6342545b..000000000000 --- a/apps/files_trashbin/appinfo/database.xml +++ /dev/null @@ -1,101 +0,0 @@ - - - - *dbname* - true - false - - utf8 - - - - *dbprefix*files_trash - - - - - auto_id - integer - 0 - true - 1 - 10 - - - - id - text - - true - 250 - - - - user - text - - true - 64 - - - - timestamp - text - - true - 12 - - - - location - text - - true - 512 - - - - type - text - - false - 4 - - - - mime - text - - false - 255 - - - - id_index - - id - ascending - - - - - timestamp_index - - timestamp - ascending - - - - - user_index - - user - ascending - - - - - -
- -
From 285595826f8c9ab20936083b4692d14ce2284905 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Tue, 8 Aug 2017 18:09:32 +0300 Subject: [PATCH 14/16] Update defaults --- .../appinfo/Migrations/Version20170804201125.php | 4 ++-- .../appinfo/Migrations/Version20170804201125.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/files_sharing/appinfo/Migrations/Version20170804201125.php b/apps/files_sharing/appinfo/Migrations/Version20170804201125.php index e0b38b478ab5..b64a258a3def 100644 --- a/apps/files_sharing/appinfo/Migrations/Version20170804201125.php +++ b/apps/files_sharing/appinfo/Migrations/Version20170804201125.php @@ -20,7 +20,7 @@ public function changeSchema(Schema $schema, array $options) { $table->addColumn('remote', 'string', [ 'notnull' => true, 'length' => 512, - 'default' => '', + 'default' => null, 'comment' => 'Url of the remote owncloud instance' ]); @@ -40,7 +40,7 @@ public function changeSchema(Schema $schema, array $options) { $table->addColumn('password', 'string', [ 'length' => 64, 'notnull' => false, - 'default' => '', + 'default' => null, 'comment' => 'Optional password for the public share' ]); diff --git a/apps/files_trashbin/appinfo/Migrations/Version20170804201125.php b/apps/files_trashbin/appinfo/Migrations/Version20170804201125.php index 4777fe6b5b1b..297205bacd8c 100644 --- a/apps/files_trashbin/appinfo/Migrations/Version20170804201125.php +++ b/apps/files_trashbin/appinfo/Migrations/Version20170804201125.php @@ -44,13 +44,13 @@ public function changeSchema(Schema $schema, array $options) { $table->addColumn('type', 'string', [ 'length' => 4, 'notnull' => false, - 'default' => '' + 'default' => null ]); $table->addColumn('mime', 'string', [ 'length' => 255, 'notnull' => false, - 'default' => '' + 'default' => null ]); $table->setPrimaryKey(['auto_id']); From 03663dca87d277717e2d52f2b291cb0f8400b7b6 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Sat, 5 Aug 2017 03:03:38 +0300 Subject: [PATCH 15/16] Session is null during installation --- lib/public/Util.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/public/Util.php b/lib/public/Util.php index 6d29e274901a..772a2456b999 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -181,9 +181,13 @@ public static function isSharingDisabledForUser() { self::$shareManager = \OC::$server->getShareManager(); } - $user = \OC::$server->getUserSession()->getUser(); - if ($user !== null) { - $user = $user->getUID(); + $userSession = \OC::$server->getUserSession(); + // session is null while installing OC + if (!is_null($userSession)){ + $user = $userSession->getUser(); + if ($user !== null) { + $user = $user->getUID(); + } } return self::$shareManager->sharingDisabledForUser($user); From 9bda9a14e3134089f48ce3a31b0effa019e673a3 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Sat, 5 Aug 2017 02:41:23 +0300 Subject: [PATCH 16/16] Defuse the bombs --- apps/files_sharing/appinfo/app.php | 2 +- apps/files_trashbin/appinfo/app.php | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php index a9b362c03a58..3b3aff15c89f 100644 --- a/apps/files_sharing/appinfo/app.php +++ b/apps/files_sharing/appinfo/app.php @@ -59,7 +59,7 @@ function() { }); $config = \OC::$server->getConfig(); -if ($config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') { +if (class_exists('OCA\Files\App') && $config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') { \OCA\Files\App::getNavigationManager()->add(function () { $l = \OC::$server->getL10N('files_sharing'); diff --git a/apps/files_trashbin/appinfo/app.php b/apps/files_trashbin/appinfo/app.php index a5d88ad7f939..453c431bd1da 100644 --- a/apps/files_trashbin/appinfo/app.php +++ b/apps/files_trashbin/appinfo/app.php @@ -28,13 +28,15 @@ // register hooks \OCA\Files_Trashbin\Trashbin::registerHooks(); -\OCA\Files\App::getNavigationManager()->add(function () { - $l = \OC::$server->getL10N('files_trashbin'); - return [ - 'id' => 'trashbin', - 'appname' => 'files_trashbin', - 'script' => 'list.php', - 'order' => 50, - 'name' => $l->t('Deleted files'), - ]; -}); +if (class_exists('OCA\Files\App')) { + \OCA\Files\App::getNavigationManager()->add(function () { + $l = \OC::$server->getL10N('files_trashbin'); + return [ + 'id' => 'trashbin', + 'appname' => 'files_trashbin', + 'script' => 'list.php', + 'order' => 50, + 'name' => $l->t('Deleted files'), + ]; + }); +}