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/Migrations/Version20170804201125.php b/apps/federatedfilesharing/appinfo/Migrations/Version20170804201125.php
new file mode 100644
index 000000000000..ce30e2fc4e76
--- /dev/null
+++ b/apps/federatedfilesharing/appinfo/Migrations/Version20170804201125.php
@@ -0,0 +1,32 @@
+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'
+ );
+ }
+ }
+}
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/database.xml b/apps/federatedfilesharing/appinfo/database.xml
deleted file mode 100644
index 1dbe8ee2ec90..000000000000
--- a/apps/federatedfilesharing/appinfo/database.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
- *dbname*
- true
- false
- utf8
-
- *dbprefix*federated_reshares
-
-
- share_id
- integer
- true
- 4
-
-
- remote_id
- integer
- true
- 4
- share ID at the remote server
-
-
- share_id_index
- true
-
- share_id
- ascending
-
-
-
-
-
diff --git a/apps/federatedfilesharing/appinfo/info.xml b/apps/federatedfilesharing/appinfo/info.xml
index 5c2cb0bdf235..db92e77c0294 100644
--- a/apps/federatedfilesharing/appinfo/info.xml
+++ b/apps/federatedfilesharing/appinfo/info.xml
@@ -5,11 +5,12 @@
Provide federated file sharing across ownCloud servers
AGPL
Bjoern Schiessle, Roeland Jago Douma
- 0.3.0
+ 0.3.1
FederatedFileSharing
+ true
other
-
+
OCA\FederatedFileSharing\AdminPanel
diff --git a/apps/files_sharing/appinfo/Migrations/Version20170804201125.php b/apps/files_sharing/appinfo/Migrations/Version20170804201125.php
new file mode 100644
index 000000000000..b64a258a3def
--- /dev/null
+++ b/apps/files_sharing/appinfo/Migrations/Version20170804201125.php
@@ -0,0 +1,94 @@
+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' => null,
+ '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' => null,
+ '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'
+ );
+ }
+ }
+}
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/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_sharing/appinfo/database.xml b/apps/files_sharing/appinfo/database.xml
deleted file mode 100644
index a70be408da4f..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
- 4
-
-
- remote
- text
- true
- 512
- Url of the remove owncloud instance
-
-
- remote_id
- integer
- -1
- true
- 4
-
-
- share_token
- text
- true
- 64
- Public share token
-
-
- password
- text
- false
- 64
- Optional password for the public share
-
-
- name
- text
- true
- 64
- Original name on the remote server
-
-
- owner
- text
- true
- 64
- User that owns the public share on the remote server
-
-
- user
- text
- true
- 64
- Local user which added the external share
-
-
- mountpoint
- text
- true
- 4000
- Full path where the share is mounted
-
-
- mountpoint_hash
- text
- true
- 32
- md5 hash of the mountpoint
-
-
- accepted
- integer
- 0
- true
- 4
-
-
- sh_external_user
-
- user
- ascending
-
-
-
- sh_external_mp
- true
-
- user
- ascending
-
-
- mountpoint_hash
- ascending
-
-
-
-
-
diff --git a/apps/files_sharing/appinfo/info.xml b/apps/files_sharing/appinfo/info.xml
index 1abc22d38ab9..6ce538d22bf7 100644
--- a/apps/files_sharing/appinfo/info.xml
+++ b/apps/files_sharing/appinfo/info.xml
@@ -10,12 +10,13 @@ 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
+ true
-
+
public.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..297205bacd8c
--- /dev/null
+++ b/apps/files_trashbin/appinfo/Migrations/Version20170804201125.php
@@ -0,0 +1,71 @@
+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' => null
+ ]);
+
+ $table->addColumn('mime', 'string', [
+ 'length' => 255,
+ 'notnull' => false,
+ 'default' => null
+ ]);
+
+ $table->setPrimaryKey(['auto_id']);
+ $table->addIndex(
+ ['id'],
+ 'id_index'
+ );
+ $table->addIndex(
+ ['timestamp'],
+ 'timestamp_index'
+ );
+ $table->addIndex(
+ ['user'],
+ 'user_index'
+ );
+ }
+ }
+}
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/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'),
+ ];
+ });
+}
diff --git a/apps/files_trashbin/appinfo/database.xml b/apps/files_trashbin/appinfo/database.xml
deleted file mode 100644
index 2944a31b02d0..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
- 4
-
-
-
- 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
-
-
-
-
-
-
-
-
diff --git a/apps/files_trashbin/appinfo/info.xml b/apps/files_trashbin/appinfo/info.xml
index d5fa18d54acd..17bfe4db3591 100644
--- a/apps/files_trashbin/appinfo/info.xml
+++ b/apps/files_trashbin/appinfo/info.xml
@@ -10,13 +10,14 @@ To prevent a user from running out of disk space, the ownCloud Deleted files app
AGPL
Bjoern Schiessle
- 0.9.0
+ 0.9.1
+ true
Files_Trashbin
-
+
user-trashbin
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/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/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]);
+ }
+ }
+ }
+}
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
diff --git a/lib/private/DB/ConnectionFactory.php b/lib/private/DB/ConnectionFactory.php
index d592d427f0e4..ef98ff570169 100644
--- a/lib/private/DB/ConnectionFactory.php
+++ b/lib/private/DB/ConnectionFactory.php
@@ -129,6 +129,9 @@ public function getConnection($type, $additionalConnectionParams) {
$additionalConnectionParams['platform'] = new OCSqlitePlatform();
$eventManager->addEventSubscriber(new SQLiteSessionInit(true, $journalMode));
break;
+ case 'pgsql':
+ $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..53a5e49c8536
--- /dev/null
+++ b/lib/private/DB/OCPostgreSqlPlatform.php
@@ -0,0 +1,95 @@
+
+ *
+ * @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\Platforms\PostgreSqlPlatform;
+use Doctrine\DBAL\Schema\ColumnDiff;
+use Doctrine\DBAL\Schema\TableDiff;
+use Doctrine\DBAL\Types\Type;
+
+class OCPostgreSqlPlatform extends PostgreSqlPlatform {
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getAlterTableSQL(TableDiff $diff){
+ $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];
+ $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)){
+ $queryColumnName = $matches[2];
+ $columnDiff = $this->findColumnDiffByName($diff, $queryColumnName);
+ if ($columnDiff){
+ if ($this->shouldSkipDropDefault($columnDiff)){
+ unset($queries[$index]);
+ continue;
+ }
+ }
+ }
+ }
+
+ return $queries;
+ }
+
+ /**
+ * 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 $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();
+ }
+
+ /**
+ * @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;
+ }
+}
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);
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));
+ }
}
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,
+ ]);
+ }
+
+}
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';