Use a meta field to store the in-progress flag [MAILPOET-1983]
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\Models;
|
||||
|
||||
use MailPoet\Util\Helpers;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
@@ -12,6 +14,7 @@ if (!defined('ABSPATH')) exit;
|
||||
* @property string|null $type
|
||||
* @property int $priority
|
||||
* @property string|null $scheduled_at
|
||||
* @property string|array|null $meta
|
||||
*/
|
||||
class ScheduledTask extends Model {
|
||||
public static $_table = MP_SCHEDULED_TASKS_TABLE;
|
||||
@@ -96,10 +99,26 @@ class ScheduledTask extends Model {
|
||||
if (!$this->priority) {
|
||||
$this->priority = self::PRIORITY_MEDIUM;
|
||||
}
|
||||
if (!Helpers::isJson($this->meta)) {
|
||||
$this->set(
|
||||
'meta',
|
||||
json_encode($this->meta)
|
||||
);
|
||||
}
|
||||
parent::save();
|
||||
return $this;
|
||||
}
|
||||
|
||||
function asArray() {
|
||||
$model = parent::asArray();
|
||||
$model['meta'] = $this->getMeta();
|
||||
return $model;
|
||||
}
|
||||
|
||||
function getMeta() {
|
||||
return (Helpers::isJson($this->meta)) ? json_decode($this->meta, true) : $this->meta;
|
||||
}
|
||||
|
||||
function delete() {
|
||||
try {
|
||||
\ORM::get_db()->beginTransaction();
|
||||
|
Reference in New Issue
Block a user