summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMichaIng <micha@dietpi.com>2021-06-05 22:18:21 +0200
committerMichaIng <micha@dietpi.com>2021-12-19 23:38:21 +0100
commit82c1beaacb92ed452afd73967c69aad68aecc0a5 (patch)
treea7abf6f3b7c7342f066ade1571084a58101b73b6 /core
parentd98e31a87218eaa1a0447c3011c8b0a9fc958bd8 (diff)
downloadnextcloud-server-82c1beaacb92ed452afd73967c69aad68aecc0a5.tar.gz
nextcloud-server-82c1beaacb92ed452afd73967c69aad68aecc0a5.zip
Enhance and complement OPcache setup checks
The current OPcache recommendations match the PHP defaults, but the values are much higher than required to run Nextcloud, even with a high number of installed apps. On the other hand, when other applications use the same OPcache instance, the recommended values might not be sufficient. Accurate recommendations need to take into account actual OPcache usage. With this commit, recommendations are shown to raise the config value if more than 90% of max cache size or number of keys is used. The checks whether the module is loaded and whether the OPcache is properly configured have been merged into a single function. This allowed to reduce the overhead of OPcache configuration checks when the module is not loaded. A check has been added whether Nextcloud is permitted to use the OPcache API. Without this, inconsistencies during core or app upgrades may cause errors and OPcache usage cannot be determined for the new usage based checks. OPcache usage based checks are skipped when Nextcloud is not permitted to use the API. Signed-off-by: MichaIng <micha@dietpi.com>
Diffstat (limited to 'core')
-rw-r--r--core/js/setupchecks.js18
-rw-r--r--core/js/tests/specs/setupchecksSpec.js112
2 files changed, 27 insertions, 103 deletions
diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js
index f5f48fdf384..59411d67b99 100644
--- a/core/js/setupchecks.js
+++ b/core/js/setupchecks.js
@@ -328,18 +328,16 @@
type: OC.SetupChecks.MESSAGE_TYPE_ERROR
});
}
- if(!data.hasOpcacheLoaded) {
- messages.push({
- msg: t('core', 'The PHP OPcache module is not loaded. {linkstart}For better performance it is recommended ↗{linkend} to load it into your PHP installation.')
- .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + data.phpOpcacheDocumentation + '">')
- .replace('{linkend}', '</a>'),
- type: OC.SetupChecks.MESSAGE_TYPE_INFO
+ if(data.OpcacheSetupRecommendations.length > 0) {
+ var listOfOPcacheRecommendations = "";
+ data.OpcacheSetupRecommendations.forEach(function(element){
+ listOfOPcacheRecommendations += "<li>" + element + "</li>";
});
- } else if(!data.isOpcacheProperlySetup) {
messages.push({
- msg: t('core', 'The PHP OPcache module is not properly configured. {linkstart}For better performance it is recommended ↗{linkend} to use the following settings in the <code>php.ini</code>:')
- .replace('{linkstart}', '<a target="_blank" rel="noreferrer noopener" class="external" href="' + data.phpOpcacheDocumentation + '">')
- .replace('{linkend}', '</a>') + "<pre><code>opcache.enable=1\nopcache.interned_strings_buffer=8\nopcache.max_accelerated_files=10000\nopcache.memory_consumption=128\nopcache.save_comments=1\nopcache.revalidate_freq=1</code></pre>",
+ msg: t(
+ 'core',
+ 'The PHP OPcache module is not properly configured:'
+ ) + "<ul>" + listOfOPcacheRecommendations + "</ul>",
type: OC.SetupChecks.MESSAGE_TYPE_INFO
});
}
diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js
index 451c49fb2e9..c3e7fab14f1 100644
--- a/core/js/tests/specs/setupchecksSpec.js
+++ b/core/js/tests/specs/setupchecksSpec.js
@@ -236,8 +236,7 @@ describe('OC.SetupChecks tests', function() {
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
- isOpcacheProperlySetup: true,
- hasOpcacheLoaded: true,
+ OpcacheSetupRecommendations: [],
isSettimelimitAvailable: true,
hasFreeTypeSupport: true,
missingIndexes: [],
@@ -294,8 +293,7 @@ describe('OC.SetupChecks tests', function() {
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
- isOpcacheProperlySetup: true,
- hasOpcacheLoaded: true,
+ OpcacheSetupRecommendations: [],
isSettimelimitAvailable: true,
hasFreeTypeSupport: true,
missingIndexes: [],
@@ -353,8 +351,7 @@ describe('OC.SetupChecks tests', function() {
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
- isOpcacheProperlySetup: true,
- hasOpcacheLoaded: true,
+ OpcacheSetupRecommendations: [],
isSettimelimitAvailable: true,
hasFreeTypeSupport: true,
missingIndexes: [],
@@ -410,8 +407,7 @@ describe('OC.SetupChecks tests', function() {
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
- isOpcacheProperlySetup: true,
- hasOpcacheLoaded: true,
+ OpcacheSetupRecommendations: [],
isSettimelimitAvailable: true,
hasFreeTypeSupport: true,
missingIndexes: [],
@@ -465,8 +461,7 @@ describe('OC.SetupChecks tests', function() {
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: false,
hasPassedCodeIntegrityCheck: true,
- isOpcacheProperlySetup: true,
- hasOpcacheLoaded: true,
+ OpcacheSetupRecommendations: [],
isSettimelimitAvailable: true,
hasFreeTypeSupport: true,
missingIndexes: [],
@@ -520,8 +515,7 @@ describe('OC.SetupChecks tests', function() {
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
- isOpcacheProperlySetup: true,
- hasOpcacheLoaded: true,
+ OpcacheSetupRecommendations: [],
isSettimelimitAvailable: true,
hasFreeTypeSupport: true,
missingIndexes: [],
@@ -577,8 +571,7 @@ describe('OC.SetupChecks tests', function() {
reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
- isOpcacheProperlySetup: true,
- hasOpcacheLoaded: true,
+ OpcacheSetupRecommendations: [],
isSettimelimitAvailable: true,
hasFreeTypeSupport: true,
missingIndexes: [],
@@ -632,8 +625,7 @@ describe('OC.SetupChecks tests', function() {
reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
- isOpcacheProperlySetup: true,
- hasOpcacheLoaded: true,
+ OpcacheSetupRecommendations: [],
isSettimelimitAvailable: false,
hasFreeTypeSupport: true,
missingIndexes: [],
@@ -687,8 +679,7 @@ describe('OC.SetupChecks tests', function() {
reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html',
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
- isOpcacheProperlySetup: true,
- hasOpcacheLoaded: true,
+ OpcacheSetupRecommendations: [],
isSettimelimitAvailable: true,
hasFreeTypeSupport: true,
missingIndexes: [],
@@ -763,8 +754,7 @@ describe('OC.SetupChecks tests', function() {
phpSupported: {eol: true, version: '5.4.0'},
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
- isOpcacheProperlySetup: true,
- hasOpcacheLoaded: true,
+ OpcacheSetupRecommendations: [],
isSettimelimitAvailable: true,
hasFreeTypeSupport: true,
missingIndexes: [],
@@ -818,8 +808,7 @@ describe('OC.SetupChecks tests', function() {
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
- isOpcacheProperlySetup: false,
- hasOpcacheLoaded: true,
+ OpcacheSetupRecommendations: ['recommendation1', 'recommendation2'],
phpOpcacheDocumentation: 'https://example.org/link/to/doc',
isSettimelimitAvailable: true,
hasFreeTypeSupport: true,
@@ -844,63 +833,7 @@ describe('OC.SetupChecks tests', function() {
async.done(function( data, s, x ){
expect(data).toEqual([{
- msg: 'The PHP OPcache module is not properly configured. <a target="_blank" rel="noreferrer noopener" class="external" href="https://example.org/link/to/doc">For better performance it is recommended ↗</a> to use the following settings in the <code>php.ini</code>:' + "<pre><code>opcache.enable=1\nopcache.interned_strings_buffer=8\nopcache.max_accelerated_files=10000\nopcache.memory_consumption=128\nopcache.save_comments=1\nopcache.revalidate_freq=1</code></pre>",
- type: OC.SetupChecks.MESSAGE_TYPE_INFO
- }]);
- done();
- });
- });
-
- it('should return an info if server has no opcache at all', 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,
- 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,
- isOpcacheProperlySetup: true,
- hasOpcacheLoaded: false,
- phpOpcacheDocumentation: 'https://example.org/link/to/doc',
- isSettimelimitAvailable: true,
- hasFreeTypeSupport: true,
- missingIndexes: [],
- missingPrimaryKeys: [],
- missingColumns: [],
- cronErrors: [],
- cronInfo: {
- diffInSeconds: 0
- },
- isMemoryLimitSufficient: true,
- appDirsWithDifferentOwner: [],
- recommendedPHPModules: [],
- pendingBigIntConversionColumns: [],
- isMysqlUsedWithoutUTF8MB4: false,
- isDefaultPhoneRegionSet: true,
- isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
- reverseProxyGeneratedURL: 'https://server',
- temporaryDirectoryWritable: true,
- })
- );
-
- async.done(function( data, s, x ){
- expect(data).toEqual([{
- msg: 'The PHP OPcache module is not loaded. <a target="_blank" rel="noreferrer noopener" class="external" href="https://example.org/link/to/doc">For better performance it is recommended ↗</a> to load it into your PHP installation.',
+ msg: 'The PHP OPcache module is not properly configured:<ul><li>recommendation1</li><li>recommendation2</li></ul>',
type: OC.SetupChecks.MESSAGE_TYPE_INFO
}]);
done();
@@ -930,8 +863,7 @@ describe('OC.SetupChecks tests', function() {
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
- isOpcacheProperlySetup: true,
- hasOpcacheLoaded: true,
+ OpcacheSetupRecommendations: [],
phpOpcacheDocumentation: 'https://example.org/link/to/doc',
isSettimelimitAvailable: true,
hasFreeTypeSupport: false,
@@ -986,8 +918,7 @@ describe('OC.SetupChecks tests', function() {
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
- isOpcacheProperlySetup: true,
- hasOpcacheLoaded: true,
+ OpcacheSetupRecommendations: [],
isSettimelimitAvailable: true,
hasFreeTypeSupport: true,
missingIndexes: [],
@@ -1045,8 +976,7 @@ describe('OC.SetupChecks tests', function() {
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
- isOpcacheProperlySetup: true,
- hasOpcacheLoaded: true,
+ OpcacheSetupRecommendations: [],
isSettimelimitAvailable: true,
hasFreeTypeSupport: true,
missingIndexes: [],
@@ -1101,8 +1031,7 @@ describe('OC.SetupChecks tests', function() {
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
- isOpcacheProperlySetup: true,
- hasOpcacheLoaded: true,
+ OpcacheSetupRecommendations: [],
isSettimelimitAvailable: true,
hasFreeTypeSupport: true,
missingIndexes: [],
@@ -1154,8 +1083,7 @@ describe('OC.SetupChecks tests', function() {
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
- isOpcacheProperlySetup: true,
- hasOpcacheLoaded: true,
+ OpcacheSetupRecommendations: [],
isSettimelimitAvailable: true,
hasFreeTypeSupport: true,
missingIndexes: [],
@@ -1209,8 +1137,7 @@ describe('OC.SetupChecks tests', function() {
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
- isOpcacheProperlySetup: true,
- hasOpcacheLoaded: true,
+ OpcacheSetupRecommendations: [],
isSettimelimitAvailable: true,
hasFreeTypeSupport: true,
missingIndexes: [],
@@ -1264,8 +1191,7 @@ describe('OC.SetupChecks tests', function() {
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
- isOpcacheProperlySetup: true,
- hasOpcacheLoaded: true,
+ OpcacheSetupRecommendations: [],
isSettimelimitAvailable: true,
hasFreeTypeSupport: true,
missingIndexes: [],