summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-12-05 21:48:10 +0100
committerGitHub <noreply@github.com>2018-12-05 21:48:10 +0100
commit0511f86c82a6684b40d0283c33a87602e0137556 (patch)
tree6155ecac95266a2bd2fc701597091a21a1ce3e9f
parent816e8f03bb570cfdd117168bfc29ad7494664339 (diff)
parent9838c91a5cf74d5e8dcd8debfccb8bc3c13a016f (diff)
downloadnextcloud-server-0511f86c82a6684b40d0283c33a87602e0137556.tar.gz
nextcloud-server-0511f86c82a6684b40d0283c33a87602e0137556.zip
Merge pull request #12853 from nextcloud/backport/12824/stable15
[stable15] Add setup check for pending bigint conversion
-rw-r--r--core/Command/Db/ConvertFilecacheBigInt.php13
-rw-r--r--core/js/setupchecks.js16
-rw-r--r--core/js/tests/specs/setupchecksSpec.js39
-rw-r--r--settings/Controller/CheckSetupController.php36
-rw-r--r--tests/Settings/Controller/CheckSetupControllerTest.php7
5 files changed, 96 insertions, 15 deletions
diff --git a/core/Command/Db/ConvertFilecacheBigInt.php b/core/Command/Db/ConvertFilecacheBigInt.php
index 5960b7aa9dd..93ada896327 100644
--- a/core/Command/Db/ConvertFilecacheBigInt.php
+++ b/core/Command/Db/ConvertFilecacheBigInt.php
@@ -23,6 +23,7 @@
namespace OC\Core\Command\Db;
+use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Types\Type;
use OC\DB\SchemaWrapper;
use OCP\IDBConnection;
@@ -51,6 +52,7 @@ class ConvertFilecacheBigInt extends Command {
}
protected function getColumnsByTable() {
+ // also update in CheckSetupController::hasBigIntConversionPendingColumns()
return [
'activity' => ['activity_id', 'object_id'],
'activity_mq' => ['mail_id'],
@@ -63,6 +65,7 @@ class ConvertFilecacheBigInt extends Command {
protected function execute(InputInterface $input, OutputInterface $output) {
$schema = new SchemaWrapper($this->connection);
+ $isSqlite = $this->connection->getDatabasePlatform() instanceof SqlitePlatform;
$updates = [];
$tables = $this->getColumnsByTable();
@@ -75,11 +78,13 @@ class ConvertFilecacheBigInt extends Command {
foreach ($columns as $columnName) {
$column = $table->getColumn($columnName);
- if ($column->getType()->getName() !== Type::BIGINT) {
+ $isAutoIncrement = $column->getAutoincrement();
+ $isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement;
+ if ($column->getType()->getName() !== Type::BIGINT && !$isAutoIncrementOnSqlite) {
$column->setType(Type::getType(Type::BIGINT));
$column->setOptions(['length' => 20]);
- $updates[] = $tableName . '.' . $columnName;
+ $updates[] = '* ' . $tableName . '.' . $columnName;
}
}
}
@@ -89,6 +94,10 @@ class ConvertFilecacheBigInt extends Command {
return 0;
}
+ $output->writeln('<comment>Following columns will be updated:</comment>');
+ $output->writeln('');
+ $output->writeln($updates);
+ $output->writeln('');
$output->writeln('<comment>This can take up to hours, depending on the number of files in your instance!</comment>');
if ($input->isInteractive()) {
diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js
index 222b12b8f40..343b676080a 100644
--- a/core/js/setupchecks.js
+++ b/core/js/setupchecks.js
@@ -337,6 +337,22 @@
type: OC.SetupChecks.MESSAGE_TYPE_INFO
})
}
+ if (data.pendingBigIntConversionColumns.length > 0) {
+ var listOfPendingBigIntConversionColumns = "";
+ data.pendingBigIntConversionColumns.forEach(function(element){
+ listOfPendingBigIntConversionColumns += "<li>" + element + "</li>";
+ });
+ messages.push({
+ msg: t(
+ 'core',
+ 'Some columns in the database are missing a conversion to big int. Due to the fact that changing column types on big tables could take some time they were not changed automatically. By running \'occ db:convert-filecache-bigint\' those pending changes could be applied manually. This operation needs to be made while the instance is offline. For further details read <a target="_blank" rel="noreferrer noopener" href="{docLink}">the documentation page about this</a>.',
+ {
+ docLink: oc_defaults.docPlaceholderUrl.replace('PLACEHOLDER', 'admin-bigint-conversion'),
+ }
+ ) + "<ul>" + listOfPendingBigIntConversionColumns + "</ul>",
+ type: OC.SetupChecks.MESSAGE_TYPE_INFO
+ })
+ }
if (data.isSqliteUsed) {
messages.push({
msg: t(
diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js
index b6b127bae53..05178a3e5cc 100644
--- a/core/js/tests/specs/setupchecksSpec.js
+++ b/core/js/tests/specs/setupchecksSpec.js
@@ -211,7 +211,8 @@ describe('OC.SetupChecks tests', function() {
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: [],
- recommendedPHPModules: []
+ recommendedPHPModules: [],
+ pendingBigIntConversionColumns: []
})
);
@@ -261,7 +262,8 @@ describe('OC.SetupChecks tests', function() {
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: [],
- recommendedPHPModules: []
+ recommendedPHPModules: [],
+ pendingBigIntConversionColumns: []
})
);
@@ -312,7 +314,8 @@ describe('OC.SetupChecks tests', function() {
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: [],
- recommendedPHPModules: []
+ recommendedPHPModules: [],
+ pendingBigIntConversionColumns: []
})
);
@@ -361,7 +364,8 @@ describe('OC.SetupChecks tests', function() {
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: [],
- recommendedPHPModules: []
+ recommendedPHPModules: [],
+ pendingBigIntConversionColumns: []
})
);
@@ -408,7 +412,8 @@ describe('OC.SetupChecks tests', function() {
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: [],
- recommendedPHPModules: []
+ recommendedPHPModules: [],
+ pendingBigIntConversionColumns: []
})
);
@@ -457,7 +462,8 @@ describe('OC.SetupChecks tests', function() {
appDirsWithDifferentOwner: [
'/some/path'
],
- recommendedPHPModules: []
+ recommendedPHPModules: [],
+ pendingBigIntConversionColumns: []
})
);
@@ -504,7 +510,8 @@ describe('OC.SetupChecks tests', function() {
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: [],
- recommendedPHPModules: []
+ recommendedPHPModules: [],
+ pendingBigIntConversionColumns: []
})
);
@@ -551,7 +558,8 @@ describe('OC.SetupChecks tests', function() {
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: [],
- recommendedPHPModules: []
+ recommendedPHPModules: [],
+ pendingBigIntConversionColumns: []
})
);
@@ -596,9 +604,10 @@ describe('OC.SetupChecks tests', function() {
cronInfo: {
diffInSeconds: 0
},
+ isMemoryLimitSufficient: false,
appDirsWithDifferentOwner: [],
recommendedPHPModules: [],
- isMemoryLimitSufficient: false
+ pendingBigIntConversionColumns: []
})
);
@@ -666,7 +675,8 @@ describe('OC.SetupChecks tests', function() {
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: [],
- recommendedPHPModules: []
+ recommendedPHPModules: [],
+ pendingBigIntConversionColumns: []
})
);
@@ -714,7 +724,8 @@ describe('OC.SetupChecks tests', function() {
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: [],
- recommendedPHPModules: []
+ recommendedPHPModules: [],
+ pendingBigIntConversionColumns: []
})
);
@@ -762,7 +773,8 @@ describe('OC.SetupChecks tests', function() {
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: [],
- recommendedPHPModules: []
+ recommendedPHPModules: [],
+ pendingBigIntConversionColumns: []
})
);
@@ -810,7 +822,8 @@ describe('OC.SetupChecks tests', function() {
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: [],
- recommendedPHPModules: []
+ recommendedPHPModules: [],
+ pendingBigIntConversionColumns: []
})
);
diff --git a/settings/Controller/CheckSetupController.php b/settings/Controller/CheckSetupController.php
index 4211b9b4c6c..92c2b1b47db 100644
--- a/settings/Controller/CheckSetupController.php
+++ b/settings/Controller/CheckSetupController.php
@@ -34,11 +34,13 @@ use bantu\IniGetWrapper\IniGetWrapper;
use DirectoryIterator;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\SqlitePlatform;
+use Doctrine\DBAL\Types\Type;
use GuzzleHttp\Exception\ClientException;
use OC;
use OC\AppFramework\Http;
use OC\DB\Connection;
use OC\DB\MissingIndexInformation;
+use OC\DB\SchemaWrapper;
use OC\IntegrityCheck\Checker;
use OC\Lock\NoopLockingProvider;
use OC\MemoryInfo;
@@ -603,6 +605,39 @@ Raw output
return $recommendedPHPModules;
}
+ protected function hasBigIntConversionPendingColumns(): array {
+ // copy of ConvertFilecacheBigInt::getColumnsByTable()
+ $tables = [
+ 'activity' => ['activity_id', 'object_id'],
+ 'activity_mq' => ['mail_id'],
+ 'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart', 'mtime', 'storage_mtime'],
+ 'mimetypes' => ['id'],
+ 'storages' => ['numeric_id'],
+ ];
+
+ $schema = new SchemaWrapper($this->db);
+ $isSqlite = $this->db->getDatabasePlatform() instanceof SqlitePlatform;
+ $pendingColumns = [];
+
+ foreach ($tables as $tableName => $columns) {
+ if (!$schema->hasTable($tableName)) {
+ continue;
+ }
+
+ $table = $schema->getTable($tableName);
+ foreach ($columns as $columnName) {
+ $column = $table->getColumn($columnName);
+ $isAutoIncrement = $column->getAutoincrement();
+ $isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement;
+ if ($column->getType()->getName() !== Type::BIGINT && !$isAutoIncrementOnSqlite) {
+ $pendingColumns[] = $tableName . '.' . $columnName;
+ }
+ }
+ }
+
+ return $pendingColumns;
+ }
+
/**
* @return DataResponse
*/
@@ -643,6 +678,7 @@ Raw output
'isMemoryLimitSufficient' => $this->memoryInfo->isMemoryLimitSufficient(),
'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(),
'recommendedPHPModules' => $this->hasRecommendedPHPModules(),
+ 'pendingBigIntConversionColumns' => $this->hasBigIntConversionPendingColumns(),
]
);
}
diff --git a/tests/Settings/Controller/CheckSetupControllerTest.php b/tests/Settings/Controller/CheckSetupControllerTest.php
index 360bd27f254..01d2178fd7f 100644
--- a/tests/Settings/Controller/CheckSetupControllerTest.php
+++ b/tests/Settings/Controller/CheckSetupControllerTest.php
@@ -159,6 +159,7 @@ class CheckSetupControllerTest extends TestCase {
'hasOpcacheLoaded',
'getAppDirsWithDifferentOwner',
'hasRecommendedPHPModules',
+ 'hasBigIntConversionPendingColumns',
])->getMock();
}
@@ -493,6 +494,11 @@ class CheckSetupControllerTest extends TestCase {
->method('hasRecommendedPHPModules')
->willReturn([]);
+ $this->checkSetupController
+ ->expects($this->once())
+ ->method('hasBigIntConversionPendingColumns')
+ ->willReturn([]);
+
$expected = new DataResponse(
[
'isGetenvServerWorking' => true,
@@ -536,6 +542,7 @@ class CheckSetupControllerTest extends TestCase {
'isMemoryLimitSufficient' => true,
'appDirsWithDifferentOwner' => [],
'recommendedPHPModules' => [],
+ 'pendingBigIntConversionColumns' => [],
]
);
$this->assertEquals($expected, $this->checkSetupController->check());