mirror of https://github.com/MISP/MISP
chg: [internal] timestamp resolution for time ranges should reorder the conditions
- always take from (smaller timestamp) to (larger timestamp), no matter the order which they were entered inpull/4023/head
parent
98248f9706
commit
dbb1e01487
|
@ -3294,13 +3294,18 @@ class Attribute extends AppModel
|
||||||
public function setTimestampConditions($timestamp, $conditions, $scope = 'Event.timestamp')
|
public function setTimestampConditions($timestamp, $conditions, $scope = 'Event.timestamp')
|
||||||
{
|
{
|
||||||
if (is_array($timestamp)) {
|
if (is_array($timestamp)) {
|
||||||
$timestamp[0] = $this->Event->resolveTimeDelta($timestamp[0]);
|
$timestamp[0] = intval($this->Event->resolveTimeDelta($timestamp[0]));
|
||||||
$timestamp[1] = $this->Event->resolveTimeDelta($timestamp[1]);
|
$timestamp[1] = intval($this->Event->resolveTimeDelta($timestamp[1]));
|
||||||
$conditions['AND'][] = array($scope . ' >=' => intval($timestamp[0]));
|
if ($timestamp[0] > $timestamp[1]) {
|
||||||
$conditions['AND'][] = array($scope . ' <=' => intval($timestamp[1]));
|
$temp = $timestamp[0];
|
||||||
|
$timestamp[0] = $timestamp[1];
|
||||||
|
$timestamp[1] = $temp;
|
||||||
|
}
|
||||||
|
$conditions['AND'][] = array($scope . ' >=' => $timestamp[0]);
|
||||||
|
$conditions['AND'][] = array($scope . ' <=' => $timestamp[1]);
|
||||||
} else {
|
} else {
|
||||||
$timestamp = $this->Event->resolveTimeDelta($timestamp);
|
$timestamp = intval($this->Event->resolveTimeDelta($timestamp));
|
||||||
$conditions['AND'][] = array($scope . ' >=' => intval($timestamp));
|
$conditions['AND'][] = array($scope . ' >=' => $timestamp);
|
||||||
}
|
}
|
||||||
return $conditions;
|
return $conditions;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue