summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-12-04 17:05:52 +0100
committerBackportbot <backportbot-noreply@rullzer.com>2018-12-04 23:34:39 +0000
commitec9d58b21d3204c34931b6f5be169f3dd22d6050 (patch)
tree2936fe4e4bb1c168eae481478252ff7004b2af0d
parentce5a6fb41b732d2a7c176c404ac86a26b5aa2bf3 (diff)
downloadnextcloud-server-ec9d58b21d3204c34931b6f5be169f3dd22d6050.tar.gz
nextcloud-server-ec9d58b21d3204c34931b6f5be169f3dd22d6050.zip
Add setup check for recommended PHP modules (i.e. Imagick, intl)
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
-rw-r--r--core/js/setupchecks.js13
-rw-r--r--core/js/tests/specs/setupchecksSpec.js37
-rw-r--r--settings/Controller/CheckSetupController.php22
-rw-r--r--tests/Settings/Controller/CheckSetupControllerTest.php7
4 files changed, 67 insertions, 12 deletions
diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js
index c50781f1485..97c28a69f68 100644
--- a/core/js/setupchecks.js
+++ b/core/js/setupchecks.js
@@ -324,6 +324,19 @@
type: OC.SetupChecks.MESSAGE_TYPE_INFO
})
}
+ if (data.recommendedPHPModules.length > 0) {
+ var listOfRecommendedPHPModules = "";
+ data.recommendedPHPModules.forEach(function(element){
+ listOfRecommendedPHPModules += "<li>" + element + "</li>";
+ });
+ messages.push({
+ msg: t(
+ 'core',
+ 'This instance is missing some recommended PHP modules. For improved performance and better compatibility it is highly recommended to install them.'
+ ) + "<ul><code>" + listOfRecommendedPHPModules + "</code></ul>",
+ type: OC.SetupChecks.MESSAGE_TYPE_INFO
+ })
+ }
if (data.isSqliteUsed) {
messages.push({
msg: t(
diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js
index b8a2164de54..b6b127bae53 100644
--- a/core/js/tests/specs/setupchecksSpec.js
+++ b/core/js/tests/specs/setupchecksSpec.js
@@ -210,7 +210,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
- appDirsWithDifferentOwner: []
+ appDirsWithDifferentOwner: [],
+ recommendedPHPModules: []
})
);
@@ -259,7 +260,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
- appDirsWithDifferentOwner: []
+ appDirsWithDifferentOwner: [],
+ recommendedPHPModules: []
})
);
@@ -309,7 +311,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
- appDirsWithDifferentOwner: []
+ appDirsWithDifferentOwner: [],
+ recommendedPHPModules: []
})
);
@@ -357,7 +360,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
- appDirsWithDifferentOwner: []
+ appDirsWithDifferentOwner: [],
+ recommendedPHPModules: []
})
);
@@ -403,7 +407,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
- appDirsWithDifferentOwner: []
+ appDirsWithDifferentOwner: [],
+ recommendedPHPModules: []
})
);
@@ -451,7 +456,8 @@ describe('OC.SetupChecks tests', function() {
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: [
'/some/path'
- ]
+ ],
+ recommendedPHPModules: []
})
);
@@ -497,7 +503,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
- appDirsWithDifferentOwner: []
+ appDirsWithDifferentOwner: [],
+ recommendedPHPModules: []
})
);
@@ -543,7 +550,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
- appDirsWithDifferentOwner: []
+ appDirsWithDifferentOwner: [],
+ recommendedPHPModules: []
})
);
@@ -589,6 +597,7 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
appDirsWithDifferentOwner: [],
+ recommendedPHPModules: [],
isMemoryLimitSufficient: false
})
);
@@ -656,7 +665,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
- appDirsWithDifferentOwner: []
+ appDirsWithDifferentOwner: [],
+ recommendedPHPModules: []
})
);
@@ -703,7 +713,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
- appDirsWithDifferentOwner: []
+ appDirsWithDifferentOwner: [],
+ recommendedPHPModules: []
})
);
@@ -750,7 +761,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
- appDirsWithDifferentOwner: []
+ appDirsWithDifferentOwner: [],
+ recommendedPHPModules: []
})
);
@@ -797,7 +809,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
- appDirsWithDifferentOwner: []
+ appDirsWithDifferentOwner: [],
+ recommendedPHPModules: []
})
);
diff --git a/settings/Controller/CheckSetupController.php b/settings/Controller/CheckSetupController.php
index e906af77bae..6d6c27ee8e6 100644
--- a/settings/Controller/CheckSetupController.php
+++ b/settings/Controller/CheckSetupController.php
@@ -583,6 +583,27 @@ Raw output
}
/**
+ * Checks for potential PHP modules that would improve the instance
+ *
+ * @return string[] A list of PHP modules that is recommended
+ */
+ protected function hasRecommendedPHPModules(): array {
+ $recommendedPHPModules = [];
+
+ if (!function_exists('grapheme_strlen')) {
+ $recommendedPHPModules[] = 'intl';
+ }
+
+ if ($this->config->getAppValue('theming', 'enabled', 'no') === 'yes') {
+ if (!extension_loaded('imagick')) {
+ $recommendedPHPModules[] = 'imagick';
+ }
+ }
+
+ return $recommendedPHPModules;
+ }
+
+ /**
* @return DataResponse
*/
public function check() {
@@ -621,6 +642,7 @@ Raw output
'mailSettingsDocumentation' => $this->urlGenerator->getAbsoluteURL('index.php/settings/admin'),
'isMemoryLimitSufficient' => $this->memoryInfo->isMemoryLimitSufficient(),
'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(),
+ 'recommendedPHPModules' => $this->hasRecommendedPHPModules(),
]
);
}
diff --git a/tests/Settings/Controller/CheckSetupControllerTest.php b/tests/Settings/Controller/CheckSetupControllerTest.php
index 7731e08eed0..e85750f6b14 100644
--- a/tests/Settings/Controller/CheckSetupControllerTest.php
+++ b/tests/Settings/Controller/CheckSetupControllerTest.php
@@ -158,6 +158,7 @@ class CheckSetupControllerTest extends TestCase {
'isPhpMailerUsed',
'hasOpcacheLoaded',
'getAppDirsWithDifferentOwner',
+ 'hasRecommendedPHPModules',
])->getMock();
}
@@ -487,6 +488,11 @@ class CheckSetupControllerTest extends TestCase {
->method('getAppDirsWithDifferentOwner')
->willReturn([]);
+ $this->checkSetupController
+ ->expects($this->once())
+ ->method('hasRecommendedPHPModules')
+ ->willReturn([]);
+
$expected = new DataResponse(
[
'isGetenvServerWorking' => true,
@@ -529,6 +535,7 @@ class CheckSetupControllerTest extends TestCase {
'mailSettingsDocumentation' => 'https://server/index.php/settings/admin',
'isMemoryLimitSufficient' => true,
'appDirsWithDifferentOwner' => [],
+ 'recommendedPHPModules' => [],
]
);
$this->assertEquals($expected, $this->checkSetupController->check());