mirror of https://github.com/MISP/MISP
fix: [server caching] only push data to redis / logs if there's something to push
- avoids the count() notice if no data was returned by the remotepull/7525/head
parent
0311b43e08
commit
3d794b62a9
|
@ -4190,12 +4190,12 @@ class Server extends AppModel
|
|||
$HttpSocket = $this->setupHttpSocket($server, $HttpSocket);
|
||||
while ($continue) {
|
||||
$i++;
|
||||
$pipe = $redis->multi(Redis::PIPELINE);
|
||||
$chunk_size = 50000;
|
||||
$data = $this->__getCachedAttributes($server, $HttpSocket, $chunk_size, $i);
|
||||
if (empty(trim($data))) {
|
||||
$continue = false;
|
||||
} else {
|
||||
$pipe = $redis->multi(Redis::PIPELINE);
|
||||
$data = explode(PHP_EOL, trim($data));
|
||||
foreach ($data as $entry) {
|
||||
list($value, $uuid) = explode(',', $entry);
|
||||
|
@ -4209,11 +4209,11 @@ class Server extends AppModel
|
|||
$redis->sAdd('misp:server_cache:event_uuid_lookup:' . $value, $server['Server']['id'] . '/' . $uuid);
|
||||
}
|
||||
}
|
||||
$pipe->exec();
|
||||
if ($jobId) {
|
||||
$job->saveField('message', 'Server ' . $server['Server']['id'] . ': ' . ((($i -1) * $chunk_size) + count($data)) . ' attributes cached.');
|
||||
}
|
||||
}
|
||||
if ($jobId) {
|
||||
$job->saveField('message', 'Server ' . $server['Server']['id'] . ': ' . ((($i -1) * $chunk_size) + count($data)) . ' attributes cached.');
|
||||
}
|
||||
$pipe->exec();
|
||||
}
|
||||
$redis->set('misp:server_cache_timestamp:' . $server['Server']['id'], time());
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue