From 9830416f64613bfcf3cffcce40c025022d1b93cc Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Thu, 14 Dec 2023 09:46:17 +0100 Subject: [PATCH] make compatible with outdated dependency packages --- .../Controller/Admin/MailConfigCheck.php | 8 +++++++ Application/Controller/Admin/SpfChecker.php | 22 ++++++++----------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Application/Controller/Admin/MailConfigCheck.php b/Application/Controller/Admin/MailConfigCheck.php index 048c885..5d793e1 100644 --- a/Application/Controller/Admin/MailConfigCheck.php +++ b/Application/Controller/Admin/MailConfigCheck.php @@ -18,6 +18,7 @@ namespace D3\MailConfigChecker\Application\Controller\Admin; use Assert\Assert; use Assert\InvalidArgumentException; use D3\MailConfigChecker\Application\Model\Exception\d3TranslatableLazyAssertionException; +use ErrorException; use Exception; use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController; use OxidEsales\Eshop\Application\Model\Shop; @@ -70,16 +71,23 @@ class MailConfigCheck extends AdminDetailsController $this->getCurrentMailer(); } + function exceptions_error_handler($severity, $message, $filename, $lineno) { + throw new ErrorException($message, 0, $severity, $filename, $lineno); + } + protected function getCurrentMailer() { try { $mail = oxNew(Email::class); $mail->setRecipient($this->testMailAddress); $mail->setBody('.'); + set_error_handler([$this, 'exceptions_error_handler']); $mail->send(); $this->addTplParam('mailer', $mail->getMailer()); } catch (Exception $e) { Registry::getUtilsView()->addErrorToDisplay($e); + } finally { + restore_error_handler(); } } } diff --git a/Application/Controller/Admin/SpfChecker.php b/Application/Controller/Admin/SpfChecker.php index 798ac38..bb0f53b 100644 --- a/Application/Controller/Admin/SpfChecker.php +++ b/Application/Controller/Admin/SpfChecker.php @@ -17,9 +17,7 @@ namespace D3\MailConfigChecker\Application\Controller\Admin; use Assert\InvalidArgumentException; use D3\MailConfigChecker\Application\Model\SpfResult; -use Mika56\SPFCheck\DNS\DNSRecordGetter; -use Mika56\SPFCheck\Model\Query; -use Mika56\SPFCheck\Model\Result; +use Mika56\SPFCheck\DNSRecordGetter; use Mika56\SPFCheck\SPFCheck; use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController; use OxidEsales\Eshop\Application\Model\Shop; @@ -84,25 +82,23 @@ class SpfChecker extends AdminDetailsController protected function checkSpfByDomain($domain, &$summarize) { $checker = new SPFCheck(new DNSRecordGetter()); - $query = new Query('', $domain); - $result = $checker->getResult($query); - switch ($result->getResult()) { - case Result::FAIL: - case Result::NEUTRAL: - case Result::PASS: - case Result::SOFTFAIL: + switch ($checker->isIPAllowed(gethostbyname($domain), $domain)) { + case SPFCheck::RESULT_FAIL: + case SPFCheck::RESULT_NEUTRAL: + case SPFCheck::RESULT_PASS: + case SPFCheck::RESULT_SOFTFAIL: $status = SpfResult::SET; break; - case Result::NONE: + case SPFCheck::RESULT_NONE: $status = SpfResult::MISSING; break; default: $status = SpfResult::ERROR; } - $rawRecord = ($record = $result->getRecord()) ? - $record->getRawRecord() : + $rawRecord = ($record = (new DNSRecordGetter())->getSPFRecordForDomain($domain)) ? + implode(', ', $record) : null; $summarize[$domain] = oxNew(SpfResult::class, $status, $rawRecord);