mirror of https://github.com/MISP/MISP
fix: [correlations] Prevent Trying to access array offset on value of type null error
parent
928de2de4b
commit
196c87963d
|
@ -681,6 +681,11 @@ class Correlation extends AppModel
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $query
|
||||
* @return array|false
|
||||
* @throws RedisException
|
||||
*/
|
||||
public function findTop(array $query)
|
||||
{
|
||||
try {
|
||||
|
@ -688,21 +693,23 @@ class Correlation extends AppModel
|
|||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$start = $query['limit'] * ($query['page'] -1);
|
||||
$end = $query['limit'] * $query['page'] - 1;
|
||||
$list = $redis->zRevRange(self::CACHE_NAME, $start, $end, true);
|
||||
$results = [];
|
||||
foreach ($list as $value => $count) {
|
||||
$realValue = $this->CorrelationValue->find('first',
|
||||
[
|
||||
'recursive' => -1,
|
||||
'conditions' => ['CorrelationValue.id' => $value],
|
||||
'fields' => 'CorrelationValue.value'
|
||||
]
|
||||
);
|
||||
|
||||
$realValues = $this->CorrelationValue->find('list', [
|
||||
'recursive' => -1,
|
||||
'conditions' => ['CorrelationValue.id' => array_keys($list)],
|
||||
'fields' => ['CorrelationValue.id', 'CorrelationValue.value'],
|
||||
]);
|
||||
|
||||
foreach ($list as $valueId => $count) {
|
||||
$value = $realValues[$valueId] ?? null;
|
||||
$results[] = [
|
||||
'Correlation' => [
|
||||
'value' => $realValue['CorrelationValue']['value'],
|
||||
'value' => $value,
|
||||
'count' => $count,
|
||||
'excluded' => $this->__preventExcludedCorrelations($value),
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue