Skip to content

Commit

Permalink
[FEATURE][IN23-252] Make EmailCatcher PHP 8.2 compatible; rework cons…
Browse files Browse the repository at this point in the history
…tructs and remove backwards compatibility for lower versions of Magento.
  • Loading branch information
borisvankatwijk committed Oct 25, 2023
1 parent ab23d22 commit ec83f49
Show file tree
Hide file tree
Showing 17 changed files with 175 additions and 317 deletions.
66 changes: 66 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,69 @@
## 4.0.0 (2023-10-25)

[View Release]([email protected]:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/4.0.0)

* [BUGFIX][IN23-251] Ported obsolete/deprecated install- and upgradeschema to db_schema.xml and db_schema_whitelist.json. *(Boris van Katwijk)*
* [FEATURE][IN23-252] Make EmailCatcher PHP 8.2 compatible; rework constructs and remove backwards compatibility for lower versions of Magento. *(Boris van Katwijk)*


## 3.5.3 (2023-08-23)

[View Release]([email protected]:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/3.5.3)

* [BUGFIX][#67][NEND-744] PHP Deprecated: Creation of dynamic property Experius\EmailCatcher\Cron\Clean::$connection is deprecated in /Cron/Clean.php on line 49 *(Boris van Katwijk)*


## 3.5.2 (2022-10-12)

[View Release]([email protected]:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/3.5.2)

* #63: ERROR - Run Cleanup *(Prashant Patel)*
* Update function imapUtf8 with check on string type *(Experius)*


## 3.5.1 (2022-07-21)

[View Release]([email protected]:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/3.5.1)

* [FEATURE][BACI-694] Changed adminhtml ui component to have dates in the grid based on timezone *(Quinn Stadens)*


## 3.5.0 (2021-02-19)

[View Release]([email protected]:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/3.5.0)

* [FEATURE] - Restored old setupscripts. Allows for reinstall on a new M2.2 environment *(Rens Wolters)*
* [FEATURE] - Added db_schema changes after removal of installscripts to installscripts *(Rens Wolters)*


## 3.4.4 (2020-11-25)

[View Release]([email protected]:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/3.4.4)

* [REFACTOR] - Fix backwards compatibility with 2.2.X *(Ruben Panis)*


## 3.4.3 (2020-11-25)

[View Release]([email protected]:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/3.4.3)

* [BUGFIX] - Add required parameter before optional parameter in constructor *(Ruben Panis)*


## 3.4.2 (2020-11-17)

[View Release]([email protected]:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/3.4.2)

* [BUGFIX] - Fixed recipient string in resend message *(Ruben Panis)*


## 3.4.1 (2020-10-27)

[View Release]([email protected]:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/3.4.1)

* [BUGFIX] fixed bug for email getting into spam cause of utf-8 *(martijnvanhaagen)*


## 3.4.0 (2020-10-22)

[View Release]([email protected]:experius/Magento-2-Module-Experius-Email-Catcher.git/commits/tag/3.4.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,23 @@
*/
declare(strict_types=1);

namespace Experius\EmailCatcher\Controller\Adminhtml\Emailcatcher;
namespace Experius\EmailCatcher\Controller\Adminhtml\EmailCatcher;

use Experius\EmailCatcher\Cron\Clean;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;

class Cleanup extends \Magento\Backend\App\Action
class Cleanup extends Action
{
/**
* @var Clean
*/
protected $clean;

/**
* Cleanup constructor.
*
* @param Context $context
* @param Clean $clean
*/
public function __construct(
Context $context,
Clean $clean
protected Clean $clean
) {
parent::__construct($context);
$this->clean = $clean;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,21 @@
*/
declare(strict_types=1);

namespace Experius\EmailCatcher\Controller\Adminhtml\Emailcatcher;
namespace Experius\EmailCatcher\Controller\Adminhtml\EmailCatcher;

use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;

class Forward extends \Magento\Backend\App\Action
{
/**
* @var PageFactory
*/
protected $resultPageFactory;

/**
* Forward constructor.
*
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory
protected PageFactory $resultPageFactory
) {
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,22 @@
*/
declare(strict_types=1);

namespace Experius\EmailCatcher\Controller\Adminhtml\Emailcatcher;
namespace Experius\EmailCatcher\Controller\Adminhtml\EmailCatcher;

use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;

class Index extends \Magento\Backend\App\Action
class Index extends Action
{
/**
* @var PageFactory
*/
protected $resultPageFactory;

/**
* Index constructor.
*
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory
protected PageFactory $resultPageFactory
) {
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,23 @@
*/
declare(strict_types=1);

namespace Experius\EmailCatcher\Controller\Adminhtml\Emailcatcher;
namespace Experius\EmailCatcher\Controller\Adminhtml\EmailCatcher;

use Experius\EmailCatcher\Model\Mail;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;

class Send extends \Magento\Backend\App\Action
class Send extends Action
{
/**
* @var Mail
*/
protected $mail;

/**
* Send constructor.
*
* @param Context $context
* @param Mail $mail
*/
public function __construct(
Context $context,
Mail $mail
protected Mail $mail
) {
parent::__construct($context);
$this->mail = $mail;
}

/**
Expand All @@ -44,7 +37,7 @@ public function execute()
$emailCatcherId = (isset($postData['emailcatcher_id'])) ? $postData['emailcatcher_id'] : false;

if (!$emailCatcherId) {
$this->messageManager->addError('Oops, something went wrong');
$this->messageManager->addErrorMessage('Oops, something went wrong');
return $resultRedirect->setPath('*/*/');
}

Expand Down
23 changes: 4 additions & 19 deletions Controller/Adminhtml/Preview/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,22 @@
namespace Experius\EmailCatcher\Controller\Adminhtml\Preview;

use Experius\EmailCatcher\Model\EmailcatcherFactory;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Controller\Result\RawFactory;

class Index extends \Magento\Backend\App\Action
class Index extends Action
{
/**
* @var RawFactory
*/
protected $resultRawFactory;

/**
* @var EmailcatcherFactory
*/
protected $emailCatcher;

/**
* Index constructor.
*
* @param Context $context
* @param RawFactory $resultRawFactory
* @param EmailcatcherFactory $emailCatcher
*/
public function __construct(
Context $context,
RawFactory $resultRawFactory,
EmailcatcherFactory $emailCatcher
protected RawFactory $resultRawFactory,
protected EmailcatcherFactory $emailCatcher
) {

$this->resultRawFactory = $resultRawFactory;
$this->emailCatcher = $emailCatcher;

parent::__construct($context);
}

Expand Down
38 changes: 9 additions & 29 deletions Cron/Clean.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,61 +18,41 @@ class Clean
const CONFIG_DAYS_TO_CLEAN = 'emailcatcher/general/days_to_clean';

/**
* @var LoggerInterface
*/
protected $logger;

/**
* @var ResourceConnection
*/
protected $resourceConnection;

/**
* @var \Magento\Framework\DB\Adapter\AdapterInterface|null
* @var \Magento\Framework\DB\Adapter\AdapterInterface
*/
protected $connection;

/**
* @var ScopeConfigInterface
*/
private $scopeConfig;

/**
* Clean constructor.
*
* @param LoggerInterface $logger
* @param ResourceConnection $resourceConnection
* @param ScopeConfigInterface $scopeConfig
*/
public function __construct(
LoggerInterface $logger,
ResourceConnection $resourceConnection,
ScopeConfigInterface $scopeConfig
protected LoggerInterface $logger,
protected ResourceConnection $resourceConnection,
protected ScopeConfigInterface $scopeConfig
) {
$this->logger = $logger;
$this->resourceConnection = $resourceConnection;
$this->connection = $this->resourceConnection->getConnection();
$this->scopeConfig = $scopeConfig;
}

/**
* Get days to clean
*
* @return int
*/
public function getDaysToClean()
public function getDaysToClean(): int
{
$daysToCleanConfig = $this->scopeConfig->getValue(self::CONFIG_DAYS_TO_CLEAN, ScopeInterface::SCOPE_STORE);
return (int)$daysToCleanConfig >= 0 ? $daysToCleanConfig : self::DEFAULT_DAYS_TO_CLEAN;

return (int)$daysToCleanConfig >= 0 ? (int)$daysToCleanConfig : self::DEFAULT_DAYS_TO_CLEAN;
}

/**
* Execute the cron
*
* @return int $deletionCount
*/
public function execute()
public function execute(): int
{
$where = "created_at < '" . date('c', time() - ($this->getDaysToClean() * (3600 * 24))) . "'";

Expand All @@ -83,6 +63,6 @@ public function execute()

$this->logger->info(__('Experius EmailCatcher Cleanup: Removed %1 records', $deletionCount));

return (int)$deletionCount;
return $deletionCount;
}
}
Loading

0 comments on commit ec83f49

Please sign in to comment.