forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
+ isOpcacheProperlySetup: true,
})
);
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
+ isOpcacheProperlySetup: true,
})
);
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
+ isOpcacheProperlySetup: true,
})
);
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
+ isOpcacheProperlySetup: true,
})
);
forwardedForHeadersWorking: true,
isCorrectMemcachedPHPModuleInstalled: false,
hasPassedCodeIntegrityCheck: true,
+ isOpcacheProperlySetup: true,
})
);
reverseProxyDocs: 'https://docs.owncloud.org/foo/bar.html',
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
+ isOpcacheProperlySetup: true,
})
);
phpSupported: {eol: true, version: '5.4.0'},
isCorrectMemcachedPHPModuleInstalled: true,
hasPassedCodeIntegrityCheck: true,
+ isOpcacheProperlySetup: true,
})
);
done();
});
});
+
+ it('should return an info if server has no proper opcache', function(done) {
+ var async = OC.SetupChecks.checkSetup();
+
+ suite.server.requests[0].respond(
+ 200,
+ {
+ 'Content-Type': 'application/json'
+ },
+ JSON.stringify({
+ isUrandomAvailable: true,
+ securityDocs: 'https://docs.owncloud.org/myDocs.html',
+ serverHasInternetConnection: true,
+ isMemcacheConfigured: true,
+ forwardedForHeadersWorking: true,
+ isCorrectMemcachedPHPModuleInstalled: true,
+ hasPassedCodeIntegrityCheck: true,
+ isOpcacheProperlySetup: false,
+ phpOpcacheDocumentation: 'https://example.org/link/to/doc',
+ })
+ );
+
+ async.done(function( data, s, x ){
+ expect(data).toEqual([{
+ msg: 'The PHP Opcache is not properly configured. <a target="_blank" rel="noreferrer" href="https://example.org/link/to/doc">For better performance we recommend ↗</a> to use following settings in the <code>php.ini</code>:' + "<pre><code>opcache.enable=On\nopcache.enable_cli=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();
+ });
+ });
});
describe('checkGeneric', function() {
namespace OC\Settings\Controller;
+use bantu\IniGetWrapper\IniGetWrapper;
use GuzzleHttp\Exception\ClientException;
use OC\AppFramework\Http;
use OC\IntegrityCheck\Checker;
return $response;
}
+ /**
+ * Checks whether a PHP opcache is properly set up
+ * @return bool
+ */
+ private function isOpcacheProperlySetup() {
+ $iniWrapper = new IniGetWrapper();
+
+ $isOpcacheProperlySetUp = true;
+
+ if(!$iniWrapper->getBool('opcache.enable')) {
+ $isOpcacheProperlySetUp = false;
+ }
+
+ if(!$iniWrapper->getBool('opcache.save_comments')) {
+ $isOpcacheProperlySetUp = false;
+ }
+
+ if(!$iniWrapper->getBool('opcache.enable_cli')) {
+ $isOpcacheProperlySetUp = false;
+ }
+
+ if($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) {
+ $isOpcacheProperlySetUp = false;
+ }
+
+ if($iniWrapper->getNumeric('opcache.memory_consumption') < 128) {
+ $isOpcacheProperlySetUp = false;
+ }
+
+ if($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) {
+ $isOpcacheProperlySetUp = false;
+ }
+
+ return $isOpcacheProperlySetUp;
+ }
+
/**
* @return DataResponse
*/
'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(),
'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(),
'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'),
+ 'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(),
+ 'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'),
]
);
}
->method('linkToDocs')
->with('admin-reverse-proxy')
->willReturn('reverse-proxy-doc-link');
+ $this->urlGenerator->expects($this->at(3))
+ ->method('linkToDocs')
+ ->with('admin-code-integrity')
+ ->willReturn('http://doc.owncloud.org/server/go.php?to=admin-code-integrity');
+ $this->urlGenerator->expects($this->at(4))
+ ->method('linkToDocs')
+ ->with('admin-php-opcache')
+ ->willReturn('http://doc.owncloud.org/server/go.php?to=admin-php-opcache');
$expected = new DataResponse(
[
'reverseProxyDocs' => 'reverse-proxy-doc-link',
'isCorrectMemcachedPHPModuleInstalled' => true,
'hasPassedCodeIntegrityCheck' => null,
- 'codeIntegrityCheckerDocumentation' => null,
+ 'codeIntegrityCheckerDocumentation' => 'http://doc.owncloud.org/server/go.php?to=admin-code-integrity',
+ 'isOpcacheProperlySetup' => false,
+ 'phpOpcacheDocumentation' => 'http://doc.owncloud.org/server/go.php?to=admin-php-opcache',
]
);
$this->assertEquals($expected, $this->checkSetupController->check());