diff --git a/core/Command/Db/ConvertFilecacheBigInt.php b/core/Command/Db/ConvertFilecacheBigInt.php index a1e3ba69f9..93ada89632 100644 --- a/core/Command/Db/ConvertFilecacheBigInt.php +++ b/core/Command/Db/ConvertFilecacheBigInt.php @@ -52,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'], diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index 222b12b8f4..343b676080 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 += "
  • " + element + "
  • "; + }); + 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 the documentation page about this.', + { + docLink: oc_defaults.docPlaceholderUrl.replace('PLACEHOLDER', 'admin-bigint-conversion'), + } + ) + "", + 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 b6b127bae5..05178a3e5c 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 4211b9b4c6..92c2b1b47d 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 360bd27f25..01d2178fd7 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());