xml_cdr catch edge case of failed import when no start stamp is present (#7207)
* xml_cdr catch edge case of failed import when no start stamp is present * xml_cdr catch edge case of failed import when no start stamp is present
This commit is contained in:
parent
5ace1902e3
commit
76af096f52
|
|
@ -638,6 +638,17 @@ if (!class_exists('xml_cdr')) {
|
|||
$this->array[$key][0]['status'] = $status;
|
||||
|
||||
//time
|
||||
//catch invalid call detail records
|
||||
if (empty($xml->variables->start_epoch)) {
|
||||
//empty the array so it can't save
|
||||
$this->array = null;
|
||||
|
||||
//move the file to the failed location
|
||||
$this->move_to_failed($this->file);
|
||||
|
||||
//stop processing
|
||||
return;
|
||||
}
|
||||
$start_epoch = urldecode($xml->variables->start_epoch);
|
||||
$this->array[$key][0]['start_epoch'] = $start_epoch;
|
||||
$this->array[$key][0]['start_stamp'] = is_numeric((int)$start_epoch) ? date('c', $start_epoch) : null;
|
||||
|
|
@ -1486,6 +1497,15 @@ if (!class_exists('xml_cdr')) {
|
|||
}
|
||||
}
|
||||
|
||||
public function moved_to_failed($failed_file) {
|
||||
$xml_cdr_dir = $this->setting->get('switch', 'log', '/var/log/freeswitch').'/xml_cdr';
|
||||
if (!file_exists($xml_cdr_dir.'/failed')) {
|
||||
if (!mkdir($xml_cdr_dir.'/failed', 0660, true)) {
|
||||
die('Failed to create '.$xml_cdr_dir.'/failed');
|
||||
}
|
||||
}
|
||||
rename($xml_cdr_dir.'/'.$failed_file, $xml_cdr_dir.'/failed/'.$failed_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* get xml from the filesystem and save it to the database
|
||||
|
|
|
|||
Loading…
Reference in New Issue