Skip to content

Commit

Permalink
add an admin check for the preview max setting
Browse files Browse the repository at this point in the history
Signed-off-by: szaimen <[email protected]>
  • Loading branch information
szaimen committed Apr 12, 2022
1 parent 483741f commit 3a17952
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
13 changes: 13 additions & 0 deletions apps/settings/lib/Controller/CheckSetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,18 @@ protected function wasEmailTestSuccessful(): bool {
return true;
}

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

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

return true;
}

protected function hasValidTransactionIsolationLevel(): bool {
try {
if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
Expand Down Expand Up @@ -846,6 +858,7 @@ public function check() {
'isReadOnlyConfig' => $this->isReadOnlyConfig(),
'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(),
'wasEmailTestSuccessful' => $this->wasEmailTestSuccessful(),
'isPreviewMaxSetCorrectly' => $this->isPreviewMaxSetCorrectly(),
'hasFileinfoInstalled' => $this->hasFileinfoInstalled(),
'hasWorkingFileLocking' => $this->hasWorkingFileLocking(),
'suggestedOverwriteCliURL' => $this->getSuggestedOverwriteCliURL(),
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 @@ -513,6 +514,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 @@ -619,6 +624,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 preview max settings are not set correctly. Please set preview_max_x and preview_max_y in your config.php file to 2048 or higher in order to fix this.',),
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
79 changes: 79 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,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -287,6 +288,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -348,6 +350,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -406,6 +409,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -463,6 +467,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -520,6 +525,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: false,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -564,6 +570,64 @@ 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,
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,
recommendedPHPModules: [],
pendingBigIntConversionColumns: [],
isMysqlUsedWithoutUTF8MB4: false,
isDefaultPhoneRegionSet: true,
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
reverseProxyGeneratedURL: 'https://server',
temporaryDirectoryWritable: true,
})
);

async.done(function( data, s, x ){
expect(data).toEqual([{
msg: 'Your preview max settings are not set correctly. Please set preview_max_x and preview_max_y in your config.php file to 2048 or higher in order to fix this.',
type: OC.SetupChecks.MESSAGE_TYPE_INFO
}]);
done();
});
});

it('should return a warning if there are app directories with wrong permissions', function(done) {
var async = OC.SetupChecks.checkSetup();

Expand All @@ -577,6 +641,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -636,6 +701,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -693,6 +759,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -750,6 +817,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -827,6 +895,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -885,6 +954,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -942,6 +1012,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -999,6 +1070,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -1060,6 +1132,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -1118,6 +1191,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -1173,6 +1247,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -1231,6 +1306,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -1289,6 +1365,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -1346,6 +1423,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down Expand Up @@ -1403,6 +1481,7 @@ describe('OC.SetupChecks tests', function() {
isGetenvServerWorking: true,
isReadOnlyConfig: false,
wasEmailTestSuccessful: true,
isPreviewMaxSetCorrectly: true,
hasWorkingFileLocking: true,
hasValidTransactionIsolationLevel: true,
suggestedOverwriteCliURL: '',
Expand Down

0 comments on commit 3a17952

Please sign in to comment.