fix: set progress value to `0` on insert new process
This commit is contained in:
parent
2eed496a89
commit
091c466ba7
|
@ -248,7 +248,7 @@ class REST_Background_Processes_Controller extends REST_Controller {
|
|||
if ( !isset($body['status']) || ($body['status'] != 'open' && $body['status'] != 'closed') ) {
|
||||
return new \WP_REST_Response([
|
||||
'error_message' => __('Status must be informed', 'tainacan' ),
|
||||
'session_id' => $session_id
|
||||
'session_id' => $id
|
||||
], 400);
|
||||
}
|
||||
|
||||
|
|
|
@ -108,12 +108,13 @@ abstract class Background_Process extends \Tainacan_WP_Background_Process {
|
|||
$this->table,
|
||||
[
|
||||
'data' => maybe_serialize($this->data),
|
||||
'progress_value' => 0,
|
||||
'user_id' => get_current_user_id(),
|
||||
'priority' => $priority,
|
||||
'action' => $this->action,
|
||||
'name' => $this->get_name(),
|
||||
'queued_on' => date('Y-m-d H:i:s'),
|
||||
'status' => 'waiting'
|
||||
'status' => 'waiting'
|
||||
]
|
||||
);
|
||||
$this->ID = $wpdb->insert_id;
|
||||
|
|
|
@ -9,9 +9,9 @@ class Background_Importer extends Background_Process {
|
|||
*/
|
||||
protected $action = 'import';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $finish_status = 1;
|
||||
|
||||
public function __construct() {
|
||||
|
@ -20,11 +20,11 @@ class Background_Importer extends Background_Process {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $status
|
||||
*/
|
||||
* @param $status
|
||||
*/
|
||||
private function set_finish_status( $status ){
|
||||
$this->finish_status = $status;
|
||||
}
|
||||
$this->finish_status = $status;
|
||||
}
|
||||
|
||||
function task($batch) {
|
||||
|
||||
|
@ -41,10 +41,10 @@ class Background_Importer extends Background_Process {
|
|||
$this->write_log($key, $object->get_log());
|
||||
$this->write_error_log($key, $object->get_error_log());
|
||||
|
||||
$batch->progress_label = $object->get_progress_label();
|
||||
$batch->progress_value = $object->get_progress_value();
|
||||
$batch->progress_label = $object->get_progress_label();
|
||||
$batch->progress_value = $object->get_progress_value();
|
||||
|
||||
$batch->data = $object->_to_Array(true);
|
||||
$batch->data = $object->_to_Array(true);
|
||||
|
||||
if (true === $object->get_abort()) {
|
||||
throw new \Exception('Process aborted by Importer');
|
||||
|
|
Loading…
Reference in New Issue