if ($check_key && $_REQUEST['ignore_processing'] === 'Y') { $fl_ignore_processing = true; } $q = fn_se_get_next_queue(); fn_echo('.'); $json_header = fn_se_get_json_header(); while (!empty($q)) { if (fn_se_check_debug()) { fn_print_r($q); } $xml = ''; $status = true; $company_id = $q['company_id']; $lang_code = $q['lang_code']; $data = (array) unserialize($q['data']); $private_key = fn_se_get_private_key($company_id, $lang_code); if (empty($private_key)) { db_query("DELETE FROM ?:se_queue WHERE queue_id = ?i", $q['queue_id']); $q = array(); continue; } //Note: $q['started'] can be in future. if ($q['status'] == 'processing' && $q['started'] + SE_MAX_PROCESSING_TIME > TIME) { if (!$fl_ignore_processing) { die('PROCESSING'); } } if ($q['error_count'] >= SE_MAX_ERROR_COUNT) { fn_se_set_import_status('sync_error', $company_id, $lang_code); die('DISABLED'); }
function fn_se_check_import_is_done($company_id = NULL, $lang_code = NULL) { $skip_time_check = false; $engines_data = fn_se_get_engines_data($company_id, $lang_code); if ($engines_data) { foreach ($engines_data as $engine_data) { $c_id = $engine_data['company_id']; $l_code = $engine_data['lang_code']; if ($engine_data['import_status'] == 'sent') { if (TIME - fn_se_get_simple_setting('last_request') > 10 || fn_se_get_simple_setting('last_request') - 10 > TIME || $skip_time_check == true) { $response = fn_se_send_request('/api/state/get/json', fn_se_get_private_key($c_id, $l_code), array('status' => '', 'full_import' => '')); $variables = fn_se_parse_state_response($response); if (!empty($variables) && isset($variables['status'])) { if ($variables['status'] == 'normal' && $variables['full_import'] == 'done') { $skip_time_check = true; fn_se_set_import_status('done', $c_id, $l_code); } elseif ($variables['status'] == 'disabled') { fn_se_set_import_status('none', $c_id, $l_code); //disable status check for disabled engine } } } } } } }