Skip to content

Commit

Permalink
Reset Limit count and offset for $table in HostController::services…
Browse files Browse the repository at this point in the history
…Action

The limit in ObjectsTable::prepareQuery() limits the number of services shown in HostController::servicesAction.
But this limit is required for pagination in ServicesController. Hence, reset the limit when this query is used
in HostController::servicesAction().
  • Loading branch information
raviks789 authored and Thomas-Gelf committed Oct 6, 2022
1 parent d1ff0d9 commit 638a359
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
8 changes: 6 additions & 2 deletions application/controllers/HostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ public function servicesAction()
$hostHasBeenCreatedInBranch = $branch->isBranch() && $host->get('id');
$content = $this->content();
$table = (new ObjectsTableService($this->db()))->setAuth($this->Auth())->setHost($host)
->setTitle($this->translate('Individual Service objects'));
->setTitle($this->translate('Individual Service objects'))
->removeQueryLimit();
if ($branch->isBranch()) {
$table->setBranchUuid($branch->getUuid());
}
Expand All @@ -226,7 +227,9 @@ public function servicesAction()
$table = (new ObjectsTableService($this->db()))
->setAuth($this->Auth())
->setHost($parent)
->setInheritedBy($host);
->setInheritedBy($host)
->removeQueryLimit();

if (count($table)) {
$content->add(
$table->setTitle(sprintf(
Expand All @@ -253,6 +256,7 @@ public function servicesAction()
// ->setHost($host)
->setAffectedHost($host)
->setTitle($title)
->removeQueryLimit()
);
}

Expand Down
9 changes: 9 additions & 0 deletions library/Director/Web/Table/IcingaServiceSetServiceTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,13 @@ public function prepareQuery()

return $query;
}

public function removeQueryLimit()
{
$query = $this->getQuery();
$query->reset($query::LIMIT_OFFSET);
$query->reset($query::LIMIT_COUNT);

return $this;
}
}
9 changes: 9 additions & 0 deletions library/Director/Web/Table/ObjectsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,13 @@ protected function prepareQuery()

return $query;
}

public function removeQueryLimit()
{
$query = $this->getQuery();
$query->reset($query::LIMIT_OFFSET);
$query->reset($query::LIMIT_COUNT);

return $this;
}
}

0 comments on commit 638a359

Please sign in to comment.