Add configuration check to Linux Cron
[MAILPOET-2507]
This commit is contained in:
committed by
Jack Kitterhing
parent
6017008548
commit
c280b2bd55
@ -8,10 +8,14 @@ class CronTrigger {
|
|||||||
/** @var SettingsController */
|
/** @var SettingsController */
|
||||||
private $settings;
|
private $settings;
|
||||||
|
|
||||||
|
const METHOD_LINUX_CRON = 'Linux Cron';
|
||||||
|
const METHOD_MAILPOET = 'MailPoet';
|
||||||
|
const METHOD_WORDPRESS = 'WordPress';
|
||||||
|
|
||||||
public static $available_methods = [
|
public static $available_methods = [
|
||||||
'mailpoet' => 'MailPoet',
|
'mailpoet' => self::METHOD_MAILPOET,
|
||||||
'wordpress' => 'WordPress',
|
'wordpress' => self::METHOD_WORDPRESS,
|
||||||
'linux_cron' => 'Linux Cron',
|
'linux_cron' => self::METHOD_LINUX_CRON,
|
||||||
'none' => 'Disabled',
|
'none' => 'Disabled',
|
||||||
];
|
];
|
||||||
const DEFAULT_METHOD = 'WordPress';
|
const DEFAULT_METHOD = 'WordPress';
|
||||||
|
@ -34,7 +34,16 @@ if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
|
|||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = \MailPoet\Cron\CronHelper::createDaemon(null);
|
|
||||||
$container = \MailPoet\DI\ContainerWrapper::getInstance(WP_DEBUG);
|
$container = \MailPoet\DI\ContainerWrapper::getInstance(WP_DEBUG);
|
||||||
|
|
||||||
|
// Check if Linux Cron method is set in plugin settings
|
||||||
|
$settings = $container->get(\MailPoet\Settings\SettingsController::class);
|
||||||
|
if ($settings->get('cron_trigger.method') !== \MailPoet\Cron\CronTrigger::METHOD_LINUX_CRON) {
|
||||||
|
echo 'MailPoet is not configured to run with Linux Cron.';
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run Cron Daemon
|
||||||
|
$data = \MailPoet\Cron\CronHelper::createDaemon(null);
|
||||||
$trigger = $container->get(\MailPoet\Cron\Daemon::class);
|
$trigger = $container->get(\MailPoet\Cron\Daemon::class);
|
||||||
$trigger->run($data);
|
$trigger->run($data);
|
||||||
|
Reference in New Issue
Block a user