make compatible with outdated dependency packages

This commit is contained in:
Daniel Seifert 2023-12-14 09:46:17 +01:00
parent e72a3da5d7
commit 9830416f64
Signed by: DanielS
GPG Key ID: 8A7C4C6ED1915C6F
2 changed files with 17 additions and 13 deletions

View File

@ -18,6 +18,7 @@ namespace D3\MailConfigChecker\Application\Controller\Admin;
use Assert\Assert; use Assert\Assert;
use Assert\InvalidArgumentException; use Assert\InvalidArgumentException;
use D3\MailConfigChecker\Application\Model\Exception\d3TranslatableLazyAssertionException; use D3\MailConfigChecker\Application\Model\Exception\d3TranslatableLazyAssertionException;
use ErrorException;
use Exception; use Exception;
use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController; use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController;
use OxidEsales\Eshop\Application\Model\Shop; use OxidEsales\Eshop\Application\Model\Shop;
@ -70,16 +71,23 @@ class MailConfigCheck extends AdminDetailsController
$this->getCurrentMailer(); $this->getCurrentMailer();
} }
function exceptions_error_handler($severity, $message, $filename, $lineno) {
throw new ErrorException($message, 0, $severity, $filename, $lineno);
}
protected function getCurrentMailer() protected function getCurrentMailer()
{ {
try { try {
$mail = oxNew(Email::class); $mail = oxNew(Email::class);
$mail->setRecipient($this->testMailAddress); $mail->setRecipient($this->testMailAddress);
$mail->setBody('.'); $mail->setBody('.');
set_error_handler([$this, 'exceptions_error_handler']);
$mail->send(); $mail->send();
$this->addTplParam('mailer', $mail->getMailer()); $this->addTplParam('mailer', $mail->getMailer());
} catch (Exception $e) { } catch (Exception $e) {
Registry::getUtilsView()->addErrorToDisplay($e); Registry::getUtilsView()->addErrorToDisplay($e);
} finally {
restore_error_handler();
} }
} }
} }

View File

@ -17,9 +17,7 @@ namespace D3\MailConfigChecker\Application\Controller\Admin;
use Assert\InvalidArgumentException; use Assert\InvalidArgumentException;
use D3\MailConfigChecker\Application\Model\SpfResult; use D3\MailConfigChecker\Application\Model\SpfResult;
use Mika56\SPFCheck\DNS\DNSRecordGetter; use Mika56\SPFCheck\DNSRecordGetter;
use Mika56\SPFCheck\Model\Query;
use Mika56\SPFCheck\Model\Result;
use Mika56\SPFCheck\SPFCheck; use Mika56\SPFCheck\SPFCheck;
use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController; use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController;
use OxidEsales\Eshop\Application\Model\Shop; use OxidEsales\Eshop\Application\Model\Shop;
@ -84,25 +82,23 @@ class SpfChecker extends AdminDetailsController
protected function checkSpfByDomain($domain, &$summarize) protected function checkSpfByDomain($domain, &$summarize)
{ {
$checker = new SPFCheck(new DNSRecordGetter()); $checker = new SPFCheck(new DNSRecordGetter());
$query = new Query('', $domain);
$result = $checker->getResult($query); switch ($checker->isIPAllowed(gethostbyname($domain), $domain)) {
switch ($result->getResult()) { case SPFCheck::RESULT_FAIL:
case Result::FAIL: case SPFCheck::RESULT_NEUTRAL:
case Result::NEUTRAL: case SPFCheck::RESULT_PASS:
case Result::PASS: case SPFCheck::RESULT_SOFTFAIL:
case Result::SOFTFAIL:
$status = SpfResult::SET; $status = SpfResult::SET;
break; break;
case Result::NONE: case SPFCheck::RESULT_NONE:
$status = SpfResult::MISSING; $status = SpfResult::MISSING;
break; break;
default: default:
$status = SpfResult::ERROR; $status = SpfResult::ERROR;
} }
$rawRecord = ($record = $result->getRecord()) ? $rawRecord = ($record = (new DNSRecordGetter())->getSPFRecordForDomain($domain)) ?
$record->getRawRecord() : implode(', ', $record) :
null; null;
$summarize[$domain] = oxNew(SpfResult::class, $status, $rawRecord); $summarize[$domain] = oxNew(SpfResult::class, $status, $rawRecord);