Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 14 additions & 1 deletion 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 All @@ -340,7 +353,7 @@
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
})
}
if (data.isPhpMailerUsed) {
if (data.isPHPMailerUsed) {
messages.push({
msg: t(
'core',
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
26 changes: 24 additions & 2 deletions settings/Controller/CheckSetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ protected function getCronErrors() {
return [];
}

protected function isPhpMailerUsed(): bool {
protected function isPHPMailerUsed(): bool {
return $this->config->getSystemValue('mail_smtpmode', 'smtp') === 'php';
}

Expand Down 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 @@ -617,10 +638,11 @@ public function check() {
'missingIndexes' => $this->hasMissingIndexes(),
'isSqliteUsed' => $this->isSqliteUsed(),
'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'),
'isPhpMailerUsed' => $this->isPhpMailerUsed(),
'isPHPMailerUsed' => $this->isPHPMailerUsed(),
'mailSettingsDocumentation' => $this->urlGenerator->getAbsoluteURL('index.php/settings/admin'),
'isMemoryLimitSufficient' => $this->memoryInfo->isMemoryLimitSufficient(),
'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(),
'recommendedPHPModules' => $this->hasRecommendedPHPModules(),
]
);
}
Expand Down
19 changes: 13 additions & 6 deletions tests/Settings/Controller/CheckSetupControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ public function setUp() {
'hasFreeTypeSupport',
'hasMissingIndexes',
'isSqliteUsed',
'isPhpMailerUsed',
'isPHPMailerUsed',
'hasOpcacheLoaded',
'getAppDirsWithDifferentOwner',
'hasRecommendedPHPModules',
])->getMock();
}

Expand Down Expand Up @@ -472,7 +473,7 @@ public function testCheck() {
]);
$this->checkSetupController
->expects($this->once())
->method('isPhpMailerUsed')
->method('isPHPMailerUsed')
->willReturn(false);
$this->checker
->expects($this->once())
Expand All @@ -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 @@ -525,16 +531,17 @@ public function testCheck() {
'isSqliteUsed' => false,
'databaseConversionDocumentation' => 'http://docs.example.org/server/go.php?to=admin-db-conversion',
'missingIndexes' => [],
'isPhpMailerUsed' => false,
'isPHPMailerUsed' => false,
'mailSettingsDocumentation' => 'https://server/index.php/settings/admin',
'isMemoryLimitSufficient' => true,
'appDirsWithDifferentOwner' => [],
'recommendedPHPModules' => [],
]
);
$this->assertEquals($expected, $this->checkSetupController->check());
}

public function testIsPhpMailerUsed() {
public function testIsPHPMailerUsed() {
$checkSetupController = $this->getMockBuilder('\OC\Settings\Controller\CheckSetupController')
->setConstructorArgs([
'settings',
Expand Down Expand Up @@ -564,8 +571,8 @@ public function testIsPhpMailerUsed() {
->with('mail_smtpmode', 'smtp')
->will($this->returnValue('not-php'));

$this->assertTrue($this->invokePrivate($checkSetupController, 'isPhpMailerUsed'));
$this->assertFalse($this->invokePrivate($checkSetupController, 'isPhpMailerUsed'));
$this->assertTrue($this->invokePrivate($checkSetupController, 'isPHPMailerUsed'));
$this->assertFalse($this->invokePrivate($checkSetupController, 'isPHPMailerUsed'));
}

public function testGetCurlVersion() {
Expand Down