Correct types in Settings

[MAILPOET-2535]
This commit is contained in:
Pavel Dohnal
2019-11-19 12:31:50 +01:00
committed by Jack Kitterhing
parent 75f1e97ee3
commit e90ba1ddda

View File

@ -104,7 +104,7 @@ class Settings extends APIEndpoint {
$task = ScheduledTask::where('type', WooCommerceSync::TASK_TYPE)
->whereRaw('status = ?', [ScheduledTask::STATUS_SCHEDULED])
->findOne();
if (!$task) {
if (!($task instanceof ScheduledTask)) {
$task = ScheduledTask::create();
$task->type = WooCommerceSync::TASK_TYPE;
$task->status = ScheduledTask::STATUS_SCHEDULED;
@ -118,12 +118,12 @@ class Settings extends APIEndpoint {
$task = ScheduledTask::where('type', InactiveSubscribers::TASK_TYPE)
->whereRaw('status = ?', [ScheduledTask::STATUS_SCHEDULED])
->findOne();
if (!$task) {
if (!($task instanceof ScheduledTask)) {
$task = ScheduledTask::create();
$task->type = InactiveSubscribers::TASK_TYPE;
$task->status = ScheduledTask::STATUS_SCHEDULED;
}
$datetime = Carbon::createFromTimestamp(WPFunctions::get()->currentTime('timestamp'));
$datetime = Carbon::createFromTimestamp((int)WPFunctions::get()->currentTime('timestamp'));
$task->scheduled_at = $datetime->subMinute();
$task->save();
}