Update method and constant name

MAILPOET-4760
This commit is contained in:
Oluwaseun Olorunsola
2022-11-28 17:06:34 +01:00
committed by Aschepikov
parent 9b9f61bf13
commit 53dda33c02
4 changed files with 12 additions and 12 deletions

View File

@ -372,7 +372,7 @@ class Settings extends APIEndpoint {
// when the user switch to a new sending method // when the user switch to a new sending method
// do not display the DisabledMailFunctionNotice // do not display the DisabledMailFunctionNotice
$this->settings->set(DisabledMailFunctionNotice::QUEUE_DISABLED_MAIL_FUNCTION_CHECK, false); $this->settings->set(DisabledMailFunctionNotice::QUEUE_DISABLED_MAIL_FUNCTION_CHECK, false);
$this->settings->set(DisabledMailFunctionNotice::OPTION_NAME, false); // do not display notice $this->settings->set(DisabledMailFunctionNotice::DISABLED_MAIL_FUNCTION_CHECK, false); // do not display notice
} }
} }

View File

@ -134,7 +134,7 @@ class Activator {
private function checkForDisabledMailFunction() { private function checkForDisabledMailFunction() {
$sendingMethodSet = $this->settings->get('mta.method', false); $sendingMethodSet = $this->settings->get('mta.method', false);
if ($sendingMethodSet === 'PHPMail' || is_bool($sendingMethodSet)) { if ($sendingMethodSet === 'PHPMail') {
// check for valid mail function // check for valid mail function
$this->settings->set(DisabledMailFunctionNotice::QUEUE_DISABLED_MAIL_FUNCTION_CHECK, true); $this->settings->set(DisabledMailFunctionNotice::QUEUE_DISABLED_MAIL_FUNCTION_CHECK, true);
} }

View File

@ -12,7 +12,7 @@ use MailPoet\WP\Notice;
class DisabledMailFunctionNotice { class DisabledMailFunctionNotice {
const OPTION_NAME = 'disabled_mail_function_check'; const DISABLED_MAIL_FUNCTION_CHECK = 'disabled_mail_function_check';
const QUEUE_DISABLED_MAIL_FUNCTION_CHECK = 'queue_disabled_mail_function_check'; const QUEUE_DISABLED_MAIL_FUNCTION_CHECK = 'queue_disabled_mail_function_check';
@ -43,7 +43,7 @@ class DisabledMailFunctionNotice {
} }
public function init($shouldDisplay): ?string { public function init($shouldDisplay): ?string {
$shouldDisplay = $shouldDisplay && $this->checkMisConfiguredFunction() && $this->checkRequirements(); $shouldDisplay = $shouldDisplay && $this->shouldCheckMisconfiguredFunction() && $this->checkRequirements();
if (!$shouldDisplay) { if (!$shouldDisplay) {
return null; return null;
} }
@ -67,7 +67,7 @@ class DisabledMailFunctionNotice {
$isMailFunctionDisabled = $this->isFunctionDisabled($functionName); $isMailFunctionDisabled = $this->isFunctionDisabled($functionName);
if ($isMailFunctionDisabled) { if ($isMailFunctionDisabled) {
$this->settings->set(DisabledMailFunctionNotice::OPTION_NAME, true); $this->settings->set(DisabledMailFunctionNotice::DISABLED_MAIL_FUNCTION_CHECK, true);
return true; return true;
} }
@ -86,9 +86,9 @@ class DisabledMailFunctionNotice {
* queue_disabled_mail_function_check === true * queue_disabled_mail_function_check === true
* *
*/ */
public function checkMisConfiguredFunction(): bool { public function shouldCheckMisconfiguredFunction(): bool {
$this->isInQueueForChecking = $this->settings->get(self::QUEUE_DISABLED_MAIL_FUNCTION_CHECK, false); $this->isInQueueForChecking = $this->settings->get(self::QUEUE_DISABLED_MAIL_FUNCTION_CHECK, false);
return $this->settings->get(self::OPTION_NAME, false) || $this->isInQueueForChecking; return $this->settings->get(self::DISABLED_MAIL_FUNCTION_CHECK, false) || $this->isInQueueForChecking;
} }
public function isFunctionDisabled(string $function): bool { public function isFunctionDisabled(string $function): bool {
@ -105,7 +105,7 @@ class DisabledMailFunctionNotice {
$message = $header . $body . $button; $message = $header . $body . $button;
Notice::displayWarning($message, '', self::OPTION_NAME, false); Notice::displayWarning($message, '', self::DISABLED_MAIL_FUNCTION_CHECK, false);
return $message; return $message;
} }
@ -137,7 +137,7 @@ class DisabledMailFunctionNotice {
* This is a workaround for detecting the user PHP mail() function is Correctly Configured and not disabled by the host * This is a workaround for detecting the user PHP mail() function is Correctly Configured and not disabled by the host
*/ */
private function testMailFunctionIsCorrectlyConfigured(): bool { private function testMailFunctionIsCorrectlyConfigured(): bool {
if ($this->settings->get(DisabledMailFunctionNotice::OPTION_NAME, false)) { if ($this->settings->get(DisabledMailFunctionNotice::DISABLED_MAIL_FUNCTION_CHECK, false)) {
return false; // skip sending mail again return false; // skip sending mail again
} }
@ -159,7 +159,7 @@ class DisabledMailFunctionNotice {
if (!$sendMailResult) { if (!$sendMailResult) {
// Error with PHP mail() function // Error with PHP mail() function
// keep displaying notice // keep displaying notice
$this->settings->set(DisabledMailFunctionNotice::OPTION_NAME, true); $this->settings->set(DisabledMailFunctionNotice::DISABLED_MAIL_FUNCTION_CHECK, true);
} }
return $sendMailResult; return $sendMailResult;

View File

@ -24,7 +24,7 @@ class DisabledMailFunctionNoticeTest extends \MailPoetTest
$this->wp = new WPFunctions; $this->wp = new WPFunctions;
$this->settings->set('mta.method', Mailer::METHOD_PHPMAIL); $this->settings->set('mta.method', Mailer::METHOD_PHPMAIL);
$this->settings->set(DisabledMailFunctionNotice::QUEUE_DISABLED_MAIL_FUNCTION_CHECK, true); $this->settings->set(DisabledMailFunctionNotice::QUEUE_DISABLED_MAIL_FUNCTION_CHECK, true);
$this->settings->set(DisabledMailFunctionNotice::OPTION_NAME, false); $this->settings->set(DisabledMailFunctionNotice::DISABLED_MAIL_FUNCTION_CHECK, false);
$this->wp->setTransient(SubscribersFeature::SUBSCRIBERS_COUNT_CACHE_KEY, 50, SubscribersFeature::SUBSCRIBERS_COUNT_CACHE_EXPIRATION_MINUTES * 60); $this->wp->setTransient(SubscribersFeature::SUBSCRIBERS_COUNT_CACHE_KEY, 50, SubscribersFeature::SUBSCRIBERS_COUNT_CACHE_EXPIRATION_MINUTES * 60);
} }
@ -111,7 +111,7 @@ class DisabledMailFunctionNoticeTest extends \MailPoetTest
expect($notice)->stringContainsString('Get ready to send your first campaign'); expect($notice)->stringContainsString('Get ready to send your first campaign');
$status = $this->settings->get(DisabledMailFunctionNotice::OPTION_NAME, false); $status = $this->settings->get(DisabledMailFunctionNotice::DISABLED_MAIL_FUNCTION_CHECK, false);
expect($status)->equals(true); expect($status)->equals(true);
} }