mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
VolatileStateResults: Prevent loops and handle empty results
This commit is contained in:
parent
ddbac68f94
commit
46c464e3bf
1 changed files with 11 additions and 3 deletions
|
|
@ -15,9 +15,12 @@ use RuntimeException;
|
|||
|
||||
class VolatileStateResults extends ResultSet
|
||||
{
|
||||
/** @var bool Whether Redis updates were applied */
|
||||
private $updatesApplied = false;
|
||||
|
||||
public function current()
|
||||
{
|
||||
if ($this->position === null && ! $this->isCacheDisabled) {
|
||||
if (! $this->updatesApplied && ! $this->isCacheDisabled) {
|
||||
$this->rewind();
|
||||
}
|
||||
|
||||
|
|
@ -26,7 +29,7 @@ class VolatileStateResults extends ResultSet
|
|||
|
||||
public function key()
|
||||
{
|
||||
if ($this->position === null && ! $this->isCacheDisabled) {
|
||||
if (! $this->updatesApplied && ! $this->isCacheDisabled) {
|
||||
$this->rewind();
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +38,8 @@ class VolatileStateResults extends ResultSet
|
|||
|
||||
public function rewind()
|
||||
{
|
||||
if ($this->position === null && ! $this->isCacheDisabled) {
|
||||
if (! $this->updatesApplied && ! $this->isCacheDisabled) {
|
||||
$this->updatesApplied = true;
|
||||
$this->advance();
|
||||
|
||||
Benchmark::measure('Applying Redis updates');
|
||||
|
|
@ -75,6 +79,10 @@ class VolatileStateResults extends ResultSet
|
|||
}
|
||||
}
|
||||
|
||||
if (empty($states)) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->fetchStates("icinga:{$type}:state", array_keys($states)) as $id => $data) {
|
||||
foreach ($data as $key => $value) {
|
||||
$data[$key] = $behaviors->retrieveProperty($value, $key);
|
||||
|
|
|
|||
Loading…
Reference in a new issue