Move exception handling from concrete workers into processTask() [MAILPOET-2385]
This commit is contained in:
@ -28,31 +28,26 @@ class InactiveSubscribers extends SingleInstanceSimpleWorker {
|
||||
|
||||
|
||||
function processTaskStrategy(ScheduledTask $task) {
|
||||
try {
|
||||
$tracking_enabled = (bool)$this->settings->get('tracking.enabled');
|
||||
if (!$tracking_enabled) {
|
||||
self::schedule();
|
||||
return true;
|
||||
}
|
||||
$days_to_inactive = (int)$this->settings->get('deactivate_subscriber_after_inactive_days');
|
||||
// Activate all inactive subscribers in case the feature is turned off
|
||||
if ($days_to_inactive === 0) {
|
||||
$this->inactive_subscribers_controller->reactivateInactiveSubscribers();
|
||||
self::schedule();
|
||||
return true;
|
||||
}
|
||||
// Handle activation/deactivation within interval
|
||||
while ($this->inactive_subscribers_controller->markInactiveSubscribers($days_to_inactive, self::BATCH_SIZE) === self::BATCH_SIZE) {
|
||||
CronHelper::enforceExecutionLimit($this->timer);
|
||||
};
|
||||
while ($this->inactive_subscribers_controller->markActiveSubscribers($days_to_inactive, self::BATCH_SIZE) === self::BATCH_SIZE) {
|
||||
CronHelper::enforceExecutionLimit($this->timer);
|
||||
};
|
||||
$tracking_enabled = (bool)$this->settings->get('tracking.enabled');
|
||||
if (!$tracking_enabled) {
|
||||
self::schedule();
|
||||
} catch (\Exception $e) {
|
||||
$this->stopProgress($task);
|
||||
throw $e;
|
||||
return true;
|
||||
}
|
||||
$days_to_inactive = (int)$this->settings->get('deactivate_subscriber_after_inactive_days');
|
||||
// Activate all inactive subscribers in case the feature is turned off
|
||||
if ($days_to_inactive === 0) {
|
||||
$this->inactive_subscribers_controller->reactivateInactiveSubscribers();
|
||||
self::schedule();
|
||||
return true;
|
||||
}
|
||||
// Handle activation/deactivation within interval
|
||||
while ($this->inactive_subscribers_controller->markInactiveSubscribers($days_to_inactive, self::BATCH_SIZE) === self::BATCH_SIZE) {
|
||||
CronHelper::enforceExecutionLimit($this->timer);
|
||||
};
|
||||
while ($this->inactive_subscribers_controller->markActiveSubscribers($days_to_inactive, self::BATCH_SIZE) === self::BATCH_SIZE) {
|
||||
CronHelper::enforceExecutionLimit($this->timer);
|
||||
};
|
||||
self::schedule();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user