Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add setup check for recommended PHP modules (i.e. Imagick, intl)
Signed-off-by: Morris Jobke <[email protected]>
  • Loading branch information
MorrisJobke authored and Backportbot committed Dec 4, 2018
commit ec9d58b21d3204c34931b6f5be169f3dd22d6050
13 changes: 13 additions & 0 deletions core/js/setupchecks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
37 changes: 25 additions & 12 deletions core/js/tests/specs/setupchecksSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: []
appDirsWithDifferentOwner: [],
recommendedPHPModules: []
})
);

Expand Down Expand Up @@ -259,7 +260,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: []
appDirsWithDifferentOwner: [],
recommendedPHPModules: []
})
);

Expand Down Expand Up @@ -309,7 +311,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: []
appDirsWithDifferentOwner: [],
recommendedPHPModules: []
})
);

Expand Down Expand Up @@ -357,7 +360,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: []
appDirsWithDifferentOwner: [],
recommendedPHPModules: []
})
);

Expand Down Expand Up @@ -403,7 +407,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: []
appDirsWithDifferentOwner: [],
recommendedPHPModules: []
})
);

Expand Down Expand Up @@ -451,7 +456,8 @@ describe('OC.SetupChecks tests', function() {
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: [
'/some/path'
]
],
recommendedPHPModules: []
})
);

Expand Down Expand Up @@ -497,7 +503,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: []
appDirsWithDifferentOwner: [],
recommendedPHPModules: []
})
);

Expand Down Expand Up @@ -543,7 +550,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: []
appDirsWithDifferentOwner: [],
recommendedPHPModules: []
})
);

Expand Down Expand Up @@ -589,6 +597,7 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
appDirsWithDifferentOwner: [],
recommendedPHPModules: [],
isMemoryLimitSufficient: false
})
);
Expand Down Expand Up @@ -656,7 +665,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: []
appDirsWithDifferentOwner: [],
recommendedPHPModules: []
})
);

Expand Down Expand Up @@ -703,7 +713,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: []
appDirsWithDifferentOwner: [],
recommendedPHPModules: []
})
);

Expand Down Expand Up @@ -750,7 +761,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: []
appDirsWithDifferentOwner: [],
recommendedPHPModules: []
})
);

Expand Down Expand Up @@ -797,7 +809,8 @@ describe('OC.SetupChecks tests', function() {
diffInSeconds: 0
},
isMemoryLimitSufficient: true,
appDirsWithDifferentOwner: []
appDirsWithDifferentOwner: [],
recommendedPHPModules: []
})
);

Expand Down
22 changes: 22 additions & 0 deletions settings/Controller/CheckSetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,27 @@ private function getAppDirsWithDifferentOwnerForAppRoot(int $currentUser, array
return $appDirsWithDifferentOwner;
}

/**
* 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
*/
Expand Down Expand Up @@ -621,6 +642,7 @@ public function check() {
'mailSettingsDocumentation' => $this->urlGenerator->getAbsoluteURL('index.php/settings/admin'),
'isMemoryLimitSufficient' => $this->memoryInfo->isMemoryLimitSufficient(),
'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(),
'recommendedPHPModules' => $this->hasRecommendedPHPModules(),
]
);
}
Expand Down
7 changes: 7 additions & 0 deletions tests/Settings/Controller/CheckSetupControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public function setUp() {
'isPhpMailerUsed',
'hasOpcacheLoaded',
'getAppDirsWithDifferentOwner',
'hasRecommendedPHPModules',
])->getMock();
}

Expand Down Expand Up @@ -487,6 +488,11 @@ public function testCheck() {
->method('getAppDirsWithDifferentOwner')
->willReturn([]);

$this->checkSetupController
->expects($this->once())
->method('hasRecommendedPHPModules')
->willReturn([]);

$expected = new DataResponse(
[
'isGetenvServerWorking' => true,
Expand Down Expand Up @@ -529,6 +535,7 @@ public function testCheck() {
'mailSettingsDocumentation' => 'https://server/index.php/settings/admin',
'isMemoryLimitSufficient' => true,
'appDirsWithDifferentOwner' => [],
'recommendedPHPModules' => [],
]
);
$this->assertEquals($expected, $this->checkSetupController->check());
Expand Down