Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
fix(api): extend ResourceRepositoryRDB::hasServiceSearch to check if …
Browse files Browse the repository at this point in the history
…host filters are used too

Resolve MON-5026
  • Loading branch information
vhr committed Mar 19, 2020
1 parent 8a03f9c commit 8702b45
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Centreon/Infrastructure/Monitoring/ResourceRepositoryRDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,27 @@ public function findResources(ResourceFilter $filter): array
*
* @return bool
*/
private function hasServiceSearch()
private function hasServiceSearch(): bool
{
return $this->extractSpecificSearchCriteria('/^service\./')
&& !$this->extractSpecificSearchCriteria('/^host\./');
}

/**
* Extract request parameters
*
* @param string $key
* @return bool
*/
private function extractSpecificSearchCriteria(string $key)
{
$requestParameters = $this->sqlRequestTranslator->getRequestParameters();
$search = $requestParameters->getSearch();

$serviceConcordances = array_reduce(
array_keys($this->serviceConcordances),
function ($acc, $concordanceKey) {
if (preg_match('/^service\./', $concordanceKey)) {
function ($acc, $concordanceKey) use ($key) {
if (preg_match($key, $concordanceKey)) {
$acc[] = $concordanceKey;
}
return $acc;
Expand Down

0 comments on commit 8702b45

Please sign in to comment.