Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add an admin check for the preview max setting #31938

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions apps/settings/lib/Controller/CheckSetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,18 @@ protected function wasEmailTestSuccessful(): bool {
return true;
}

protected function isPreviewMaxSetCorrectly(): bool {
if ($this->config->getSystemValueInt('preview_max_x', 4096) < 4096) {
return false;
}

if ($this->config->getSystemValueInt('preview_max_y', 4096) < 4096) {
return false;
}

return true;
}

protected function hasValidTransactionIsolationLevel(): bool {
try {
if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
Expand Down Expand Up @@ -867,6 +879,7 @@ public function check() {
'isReadOnlyConfig' => $this->isReadOnlyConfig(),
'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(),
'wasEmailTestSuccessful' => $this->wasEmailTestSuccessful(),
'isPreviewMaxSetCorrectly' => $this->isPreviewMaxSetCorrectly(),
'hasFileinfoInstalled' => $this->hasFileinfoInstalled(),
'hasWorkingFileLocking' => $this->hasWorkingFileLocking(),
'hasDBFileLocking' => $this->hasDBFileLocking(),
Expand Down
6 changes: 6 additions & 0 deletions apps/settings/tests/Controller/CheckSetupControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ protected function setUp(): void {
->setMethods([
'isReadOnlyConfig',
'wasEmailTestSuccessful',
'isPreviewMaxSetCorrectly',
'hasValidTransactionIsolationLevel',
'hasFileinfoInstalled',
'hasWorkingFileLocking',
Expand Down Expand Up @@ -491,6 +492,10 @@ public function testCheck() {
->expects($this->once())
->method('wasEmailTestSuccessful')
->willReturn(false);
$this->checkSetupController
->expects($this->once())
->method('isPreviewMaxSetCorrectly')
->willReturn(true);
$this->checkSetupController
->expects($this->once())
->method('hasValidTransactionIsolationLevel')
Expand Down Expand Up @@ -606,6 +611,7 @@ public function testCheck() {
'isGetenvServerWorking' => true,
'isReadOnlyConfig' => false,
'wasEmailTestSuccessful' => false,
'isPreviewMaxSetCorrectly' => true,
'hasValidTransactionIsolationLevel' => true,
'hasFileinfoInstalled' => true,
'hasWorkingFileLocking' => true,
Expand Down
6 changes: 6 additions & 0 deletions core/js/setupchecks.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@
type: OC.SetupChecks.MESSAGE_TYPE_INFO
});
}
if (!data.isPreviewMaxSetCorrectly) {
messages.push({
msg: t('core', 'Your max preview size settings are lower than 4K. Image previews may appear blurry to people using 4K screens.'),
type: OC.SetupChecks.MESSAGE_TYPE_INFO
});
}
if (!data.hasValidTransactionIsolationLevel) {
messages.push({
msg: t('core', 'Your database does not run with "READ COMMITTED" transaction isolation level. This can cause problems when multiple actions are executed in parallel.'),
Expand Down
83 changes: 83 additions & 0 deletions core/js/tests/specs/setupchecksSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -289,6 +290,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -352,6 +354,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -412,6 +415,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -471,6 +475,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -530,6 +535,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: false,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -635,6 +641,66 @@ describe('OC.SetupChecks tests', function() {
});
});

it('should return an info when preview max is not configured correctly', function(done) {
var async = OC.SetupChecks.checkSetup();

suite.server.requests[0].respond(
200,
{
'Content-Type': 'application/json'
},
JSON.stringify({
hasFileinfoInstalled: true,
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: false,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
isRandomnessSecure: true,
securityDocs: 'https://docs.nextcloud.com/myDocs.html',
isFairUseOfFreePushService: true,
serverHasInternetConnectionProblems: false,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
OpcacheSetupRecommendations: [],
isSettimelimitAvailable: true,
hasFreeTypeSupport: true,
missingIndexes: [],
missingPrimaryKeys: [],
missingColumns: [],
cronErrors: [],
cronInfo: {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: [],
isImagickEnabled: true,
areWebauthnExtensionsEnabled: true,
is64bit: true,
recommendedPHPModules: [],
pendingBigIntConversionColumns: [],
isMysqlUsedWithoutUTF8MB4: false,
isDefaultPhoneRegionSet: true,
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
reverseProxyGeneratedURL: 'https://server',
temporaryDirectoryWritable: true,
})
);

async.done(function( data, s, x ){
expect(data).toEqual([{
msg: 'Your max preview size settings are lower than 4K. Image previews may appear blurry to people using 4K screens.',
type: OC.SetupChecks.MESSAGE_TYPE_INFO
}]);
done();
});
});

it('should return an info if database file locking is used', function(done) {
var async = OC.SetupChecks.checkSetup();

Expand All @@ -648,6 +714,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: true,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -707,6 +774,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -768,6 +836,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -827,6 +896,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -886,6 +956,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -965,6 +1036,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -1025,6 +1097,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -1084,6 +1157,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -1143,6 +1217,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -1206,6 +1281,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -1266,6 +1342,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -1323,6 +1400,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -1383,6 +1461,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -1443,6 +1522,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -1502,6 +1582,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -1561,6 +1642,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down Expand Up @@ -1620,6 +1702,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasDBFileLocking: false,
hasValidTransactionIsolationLevel: true,
Expand Down