Deactivate action scheduler recurring actions on plugin deactivation
We need to cleanup these recurring actions otherwise they would be rescheduled indefinitely. [MAILPOET-4274]
This commit is contained in:
committed by
Veljko V
parent
e3fbf2421d
commit
272e875643
@@ -7,7 +7,9 @@ use MailPoet\AutomaticEmails\AutomaticEmails;
|
||||
use MailPoet\Automation\Engine\Engine;
|
||||
use MailPoet\Automation\Engine\Hooks as AutomationHooks;
|
||||
use MailPoet\Automation\Integrations\MailPoet\MailPoetIntegration;
|
||||
use MailPoet\Cron\ActionScheduler\ActionScheduler;
|
||||
use MailPoet\Cron\CronTrigger;
|
||||
use MailPoet\Cron\DaemonActionSchedulerRunner;
|
||||
use MailPoet\Features\FeaturesController;
|
||||
use MailPoet\InvalidStateException;
|
||||
use MailPoet\PostEditorBlocks\PostEditorBlock;
|
||||
@@ -102,9 +104,12 @@ class Initializer {
|
||||
/** @var FeaturesController */
|
||||
private $featuresController;
|
||||
|
||||
/*** @var PersonalDataExporters */
|
||||
/** @var PersonalDataExporters */
|
||||
private $personalDataExporters;
|
||||
|
||||
/** @var ActionScheduler */
|
||||
private $actionScheduler;
|
||||
|
||||
const INITIALIZED = 'MAILPOET_INITIALIZED';
|
||||
|
||||
public function __construct(
|
||||
@@ -133,7 +138,8 @@ class Initializer {
|
||||
Engine $automationEngine,
|
||||
MailPoetIntegration $automationMailPoetIntegration,
|
||||
FeaturesController $featuresController,
|
||||
PersonalDataExporters $personalDataExporters
|
||||
PersonalDataExporters $personalDataExporters,
|
||||
ActionScheduler $actionScheduler
|
||||
) {
|
||||
$this->rendererFactory = $rendererFactory;
|
||||
$this->accessControl = $accessControl;
|
||||
@@ -161,6 +167,7 @@ class Initializer {
|
||||
$this->automationMailPoetIntegration = $automationMailPoetIntegration;
|
||||
$this->featuresController = $featuresController;
|
||||
$this->personalDataExporters = $personalDataExporters;
|
||||
$this->actionScheduler = $actionScheduler;
|
||||
}
|
||||
|
||||
public function init() {
|
||||
@@ -192,6 +199,15 @@ class Initializer {
|
||||
]
|
||||
);
|
||||
|
||||
// deactivation function
|
||||
$this->wpFunctions->registerDeactivationHook(
|
||||
Env::$file,
|
||||
[
|
||||
$this,
|
||||
'runDeactivation',
|
||||
]
|
||||
);
|
||||
|
||||
$this->wpFunctions->addAction('activated_plugin', [
|
||||
new PluginActivatedHook(new DeferredAdminNotices),
|
||||
'action',
|
||||
@@ -439,6 +455,12 @@ class Initializer {
|
||||
return array_merge($tables, $mailpoetTables);
|
||||
}
|
||||
|
||||
public function runDeactivation() {
|
||||
// Unschedule recurring action scheduler actions
|
||||
$this->actionScheduler->unscheduleAction(DaemonActionSchedulerRunner::DAEMON_RUN_SCHEDULER_ACTION);
|
||||
$this->actionScheduler->unscheduleAction(DaemonActionSchedulerRunner::DAEMON_TRIGGER_SCHEDULER_ACTION);
|
||||
}
|
||||
|
||||
private function setupWoocommerceTransactionalEmails() {
|
||||
$wcEnabled = $this->wcHelper->isWooCommerceActive();
|
||||
$optInEnabled = $this->settings->get('woocommerce.use_mailpoet_editor', false);
|
||||
|
Reference in New Issue
Block a user