From 6a0c54d5bfd70baeed2438ac05278a9b4cb73d88 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 19 Jun 2018 16:39:51 +0200 Subject: [PATCH] Add warning to setup checks if the default mailer is still php Signed-off-by: Roeland Jago Douma --- core/js/setupchecks.js | 12 +++++++++ settings/Controller/CheckSetupController.php | 6 +++++ .../Controller/CheckSetupControllerTest.php | 27 ++++++++++++++++++- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index eae0abae50..75d335043a 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -293,6 +293,18 @@ type: OC.SetupChecks.MESSAGE_TYPE_WARNING }) } + if (data.isPhpMailerUsed) { + messages.push({ + msg: t( + 'core', + 'Use of the the built in php mailer is no longer supported. Please update your email server settings ↗.', + { + docLink: data.mailSettingsDocumentation, + } + ), + type: OC.SetupChecks.MESSAGE_TYPE_WARNING + }); + } } else { messages.push({ msg: t('core', 'Error occurred while checking server setup'), diff --git a/settings/Controller/CheckSetupController.php b/settings/Controller/CheckSetupController.php index ecbb9839c7..a301ecb1f6 100644 --- a/settings/Controller/CheckSetupController.php +++ b/settings/Controller/CheckSetupController.php @@ -523,6 +523,10 @@ Raw output return []; } + protected function isPhpMailerUsed(): bool { + return $this->config->getSystemValue('mail_smtpmode', 'php') === 'php'; + } + /** * @return DataResponse */ @@ -557,6 +561,8 @@ Raw output 'missingIndexes' => $this->hasMissingIndexes(), 'isSqliteUsed' => $this->isSqliteUsed(), 'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'), + 'isPhpMailerUsed' => $this->isPhpMailerUsed(), + 'mailSettingsDocumentation' => $this->urlGenerator->getAbsoluteURL('index.php/settings/admin') ] ); } diff --git a/tests/Settings/Controller/CheckSetupControllerTest.php b/tests/Settings/Controller/CheckSetupControllerTest.php index 470bc9cde6..057774a45b 100644 --- a/tests/Settings/Controller/CheckSetupControllerTest.php +++ b/tests/Settings/Controller/CheckSetupControllerTest.php @@ -119,7 +119,22 @@ class CheckSetupControllerTest extends TestCase { $this->lockingProvider, $this->dateTimeFormatter, ]) - ->setMethods(['isReadOnlyConfig', 'hasValidTransactionIsolationLevel', 'hasFileinfoInstalled', 'hasWorkingFileLocking', 'getLastCronInfo', 'getSuggestedOverwriteCliURL', 'getOutdatedCaches', 'getCurlVersion', 'isPhpOutdated', 'isOpcacheProperlySetup', 'hasFreeTypeSupport', 'hasMissingIndexes', 'isSqliteUsed'])->getMock(); + ->setMethods([ + 'isReadOnlyConfig', + 'hasValidTransactionIsolationLevel', + 'hasFileinfoInstalled', + 'hasWorkingFileLocking', + 'getLastCronInfo', + 'getSuggestedOverwriteCliURL', + 'getOutdatedCaches', + 'getCurlVersion', + 'isPhpOutdated', + 'isOpcacheProperlySetup', + 'hasFreeTypeSupport', + 'hasMissingIndexes', + 'isSqliteUsed', + 'isPhpMailerUsed', + ])->getMock(); } public function testIsInternetConnectionWorkingDisabledViaConfig() { @@ -352,6 +367,10 @@ class CheckSetupControllerTest extends TestCase { ->method('linkToDocs') ->with('admin-db-conversion') ->willReturn('http://docs.example.org/server/go.php?to=admin-db-conversion'); + $this->urlGenerator->expects($this->at(6)) + ->method('getAbsoluteURL') + ->with('index.php/settings/admin') + ->willReturn('https://server/index.php/settings/admin'); $this->checkSetupController ->method('hasFreeTypeSupport') ->willReturn(false); @@ -392,6 +411,10 @@ class CheckSetupControllerTest extends TestCase { 'relativeTime' => '2 hours ago', 'backgroundJobsUrl' => 'https://example.org', ]); + $this->checkSetupController + ->expects($this->once()) + ->method('isPhpMailerUsed') + ->willReturn(false); $this->checker ->expects($this->once()) ->method('hasPassedCheck') @@ -434,6 +457,8 @@ class CheckSetupControllerTest extends TestCase { 'isSqliteUsed' => false, 'databaseConversionDocumentation' => 'http://docs.example.org/server/go.php?to=admin-db-conversion', 'missingIndexes' => [], + 'isPhpMailerUsed' => false, + 'mailSettingsDocumentation' => 'https://server/index.php/settings/admin', ] ); $this->assertEquals($expected, $this->checkSetupController->check());