summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-10-02 16:17:56 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-10-06 08:51:47 +0200
commitb51996540889b29b3b1d2bc118f652c7b942404b (patch)
tree9c324a8f8d93c27b4ee4f72a220ff3989813506f
parent3ff60cc2e3a47efd9796b5376694743c168efeb3 (diff)
downloadnextcloud-server-b51996540889b29b3b1d2bc118f652c7b942404b.tar.gz
nextcloud-server-b51996540889b29b3b1d2bc118f652c7b942404b.zip
[admin] check for correct PHP memcached module
-rw-r--r--core/js/setupchecks.js6
-rw-r--r--core/js/tests/specs/setupchecksSpec.js46
-rw-r--r--settings/controller/checksetupcontroller.php18
-rw-r--r--tests/settings/controller/CheckSetupControllerTest.php1
4 files changed, 65 insertions, 6 deletions
diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js
index 2e21c6ad725..6e2058d54fc 100644
--- a/core/js/setupchecks.js
+++ b/core/js/setupchecks.js
@@ -98,6 +98,12 @@
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
});
}
+ if(!data.isCorrectMemcachedPHPModuleInstalled) {
+ messages.push({
+ msg: t('core', 'Memcached is configured as distributed cache, but the wrong PHP module "memcache" is installed. \\OC\\Memcache\\Memcached only supports "memcached" and not "memcache". See the <a href="{wikiLink}">memcached wiki about both modules</a>.', {wikiLink: 'https://code.google.com/p/memcached/wiki/PHPClientComparison'}),
+ type: OC.SetupChecks.MESSAGE_TYPE_WARNING
+ });
+ }
} else {
messages.push({
msg: t('core', 'Error occurred while checking server setup'),
diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js
index c70ea0ff9fa..8dd2214621a 100644
--- a/core/js/tests/specs/setupchecksSpec.js
+++ b/core/js/tests/specs/setupchecksSpec.js
@@ -73,7 +73,8 @@ describe('OC.SetupChecks tests', function() {
isUrandomAvailable: true,
serverHasInternetConnection: false,
memcacheDocs: 'https://doc.owncloud.org/server/go.php?to=admin-performance',
- forwardedForHeadersWorking: true
+ forwardedForHeadersWorking: true,
+ isCorrectMemcachedPHPModuleInstalled: true,
})
);
@@ -106,7 +107,8 @@ describe('OC.SetupChecks tests', function() {
serverHasInternetConnection: false,
dataDirectoryProtected: false,
memcacheDocs: 'https://doc.owncloud.org/server/go.php?to=admin-performance',
- forwardedForHeadersWorking: true
+ forwardedForHeadersWorking: true,
+ isCorrectMemcachedPHPModuleInstalled: true,
})
);
@@ -141,7 +143,8 @@ describe('OC.SetupChecks tests', function() {
serverHasInternetConnection: false,
dataDirectoryProtected: false,
isMemcacheConfigured: true,
- forwardedForHeadersWorking: true
+ forwardedForHeadersWorking: true,
+ isCorrectMemcachedPHPModuleInstalled: true,
})
);
@@ -173,7 +176,8 @@ describe('OC.SetupChecks tests', function() {
serverHasInternetConnection: true,
dataDirectoryProtected: true,
isMemcacheConfigured: true,
- forwardedForHeadersWorking: true
+ forwardedForHeadersWorking: true,
+ isCorrectMemcachedPHPModuleInstalled: true,
})
);
@@ -186,6 +190,34 @@ describe('OC.SetupChecks tests', function() {
});
});
+ it('should return an error if the wrong memcache PHP module is installed', 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,
+ dataDirectoryProtected: true,
+ isMemcacheConfigured: true,
+ forwardedForHeadersWorking: true,
+ isCorrectMemcachedPHPModuleInstalled: false,
+ })
+ );
+
+ async.done(function( data, s, x ){
+ expect(data).toEqual([{
+ msg: 'Memcached is configured as distributed cache, but the wrong PHP module "memcache" is installed. \\OC\\Memcache\\Memcached only supports "memcached" and not "memcache". See the <a href="https://code.google.com/p/memcached/wiki/PHPClientComparison">memcached wiki about both modules</a>.',
+ type: OC.SetupChecks.MESSAGE_TYPE_WARNING
+ }]);
+ done();
+ });
+ });
+
it('should return an error if the forwarded for headers are not working', function(done) {
var async = OC.SetupChecks.checkSetup();
@@ -200,7 +232,8 @@ describe('OC.SetupChecks tests', function() {
dataDirectoryProtected: true,
isMemcacheConfigured: true,
forwardedForHeadersWorking: false,
- reverseProxyDocs: 'https://docs.owncloud.org/foo/bar.html'
+ reverseProxyDocs: 'https://docs.owncloud.org/foo/bar.html',
+ isCorrectMemcachedPHPModuleInstalled: true,
})
);
@@ -248,7 +281,8 @@ describe('OC.SetupChecks tests', function() {
dataDirectoryProtected: true,
isMemcacheConfigured: true,
forwardedForHeadersWorking: true,
- phpSupported: {eol: true, version: '5.4.0'}
+ phpSupported: {eol: true, version: '5.4.0'},
+ isCorrectMemcachedPHPModuleInstalled: true,
})
);
diff --git a/settings/controller/checksetupcontroller.php b/settings/controller/checksetupcontroller.php
index ca4eb255f6b..34fe824bc97 100644
--- a/settings/controller/checksetupcontroller.php
+++ b/settings/controller/checksetupcontroller.php
@@ -211,6 +211,23 @@ class CheckSetupController extends Controller {
}
/**
+ * Checks if the correct memcache module for PHP is installed. Only
+ * fails if memcached is configured and the working module is not installed.
+ *
+ * @return bool
+ */
+ private function isCorrectMemcachedPHPModuleInstalled() {
+ if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') {
+ return true;
+ }
+
+ // there are two different memcached modules for PHP
+ // we only support memcached and not memcache
+ // https://code.google.com/p/memcached/wiki/PHPClientComparison
+ return !extension_loaded('memcached') && extension_loaded('memcache');
+ }
+
+ /**
* @return DataResponse
*/
public function check() {
@@ -226,6 +243,7 @@ class CheckSetupController extends Controller {
'phpSupported' => $this->isPhpSupported(),
'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(),
'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'),
+ 'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled()
]
);
}
diff --git a/tests/settings/controller/CheckSetupControllerTest.php b/tests/settings/controller/CheckSetupControllerTest.php
index 2a8a6548ebb..c453822464f 100644
--- a/tests/settings/controller/CheckSetupControllerTest.php
+++ b/tests/settings/controller/CheckSetupControllerTest.php
@@ -346,6 +346,7 @@ class CheckSetupControllerTest extends TestCase {
],
'forwardedForHeadersWorking' => true,
'reverseProxyDocs' => 'reverse-proxy-doc-link',
+ 'isCorrectMemcachedPHPModuleInstalled' => true,
]
);
$this->assertEquals($expected, $this->checkSetupController->check());