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

fix(platform): Fix database name with special chars #11619

Merged
merged 1 commit into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion www/api/class/centreon_performance_service.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ public function getList()
}

if ($excludeAnomalyDetection) {
$additionalCondition .= 'AND s.service_id NOT IN (SELECT service_id FROM ' . $conf_centreon['db'] . '.mod_anomaly_service) ';
$additionalCondition .= 'AND s.service_id NOT IN (SELECT service_id
FROM `' . $conf_centreon['db'] . '`.mod_anomaly_service) ';
}
if (isset($this->arguments['hostgroup'])) {
$additionalCondition .= 'AND (hg.host_id = i.host_id ' .
Expand Down
17 changes: 9 additions & 8 deletions www/api/class/centreon_topcounter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -847,19 +847,20 @@ protected function checkChangeState($pollerId, $lastRestart)

$query = "SELECT * FROM log_action WHERE action_log_date > $lastRestart " .
"AND ((object_type = 'host' AND ((action_type = 'd' AND object_id IN (SELECT host_id FROM hosts)) " .
"OR object_id IN (SELECT host_host_id FROM " .
$conf_centreon['db'] . ".ns_host_relation WHERE nagios_server_id = '$pollerId'))) " .
"OR object_id IN (SELECT host_host_id FROM `" .
$conf_centreon['db'] . "`.ns_host_relation WHERE nagios_server_id = '$pollerId'))) " .
"OR (object_type = 'service' AND ((action_type = 'd' AND object_id IN (SELECT service_id FROM services)) OR " .

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARN: Line exceeds 120 characters; contains 123 characters

"object_id IN (SELECT service_service_id FROM " .
$conf_centreon['db'] . ".ns_host_relation nhr, " . $conf_centreon['db'] . ".host_service_relation hsr " .
"object_id IN (SELECT service_service_id FROM `" .
$conf_centreon['db'] . "`.ns_host_relation nhr, `" . $conf_centreon['db'] . "`.host_service_relation hsr " .
"WHERE nagios_server_id = '$pollerId' AND hsr.host_host_id = nhr.host_host_id)))" .
"OR (object_type = 'servicegroup' AND ((action_type = 'd' AND object_id IN (SELECT DISTINCT servicegroup_id " .

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARN: Line exceeds 120 characters; contains 123 characters

"FROM services_servicegroups)) OR object_id IN (SELECT DISTINCT servicegroup_sg_id FROM " .
$conf_centreon['db'] . ".servicegroup_relation sgr, " . $conf_centreon['db'] . ".ns_host_relation nhr " .
"FROM services_servicegroups)) OR object_id IN (SELECT DISTINCT servicegroup_sg_id FROM `" .
$conf_centreon['db'] . "`.servicegroup_relation sgr,
`" . $conf_centreon['db'] . "`.ns_host_relation nhr " .
"WHERE sgr.host_host_id = nhr.host_host_id AND nhr.nagios_server_id = '$pollerId')))" .
"OR (object_type = 'hostgroup' AND ((action_type = 'd' AND object_id IN (SELECT DISTINCT hostgroup_id " .
"FROM hosts_hostgroups)) OR object_id IN (SELECT DISTINCT hr.hostgroup_hg_id FROM " .
$conf_centreon['db'] . ".hostgroup_relation hr, " . $conf_centreon['db'] . ".ns_host_relation nhr " .
"FROM hosts_hostgroups)) OR object_id IN (SELECT DISTINCT hr.hostgroup_hg_id FROM `" .
$conf_centreon['db'] . "`.hostgroup_relation hr, `" . $conf_centreon['db'] . "`.ns_host_relation nhr " .
"WHERE hr.host_host_id = nhr.host_host_id AND nhr.nagios_server_id = '$pollerId'))))";

try {
Expand Down
16 changes: 8 additions & 8 deletions www/include/configuration/configServers/DB-Func.php
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ function getChangeState(array $pollers): array
UNION
SELECT instance_id, COUNT(*) as num_logs, MAX(action_log_date) as action_log_date FROM log_action
INNER JOIN (
SELECT nagios_server_id as instance_id, host_host_id as host_id FROM {$conf_centreon['db']}.ns_host_relation
SELECT nagios_server_id as instance_id, host_host_id as host_id FROM `{$conf_centreon['db']}`.ns_host_relation
WHERE nagios_server_id IN ($pollersSearch)
) AS subtable ON log_action.object_id = subtable.host_id
WHERE log_action.object_type = 'host' AND action_log_date > $lastRestart GROUP BY subtable.instance_id
Expand All @@ -1082,7 +1082,7 @@ function getChangeState(array $pollers): array
SELECT instance_id, COUNT(*) as num_logs, MAX(action_log_date) as action_log_date FROM log_action
INNER JOIN (
SELECT nagios_server_id as instance_id, service_service_id as service_id
FROM {$conf_centreon['db']}.ns_host_relation nhr, {$conf_centreon['db']}.host_service_relation hsr
FROM `{$conf_centreon['db']}`.ns_host_relation nhr, `{$conf_centreon['db']}`.host_service_relation hsr
WHERE nagios_server_id IN ($pollersSearch)
AND hsr.host_host_id = nhr.host_host_id
) AS subtable ON log_action.object_id = subtable.service_id
Expand All @@ -1099,7 +1099,7 @@ function getChangeState(array $pollers): array
SELECT instance_id, COUNT(*) as num_logs, MAX(action_log_date) as action_log_date FROM log_action
INNER JOIN (
SELECT nhr.nagios_server_id as instance_id, servicegroup_sg_id as servicegroup_id
FROM {$conf_centreon['db']}.servicegroup_relation sgr, {$conf_centreon['db']}.ns_host_relation nhr
FROM `{$conf_centreon['db']}`.servicegroup_relation sgr, `{$conf_centreon['db']}`.ns_host_relation nhr
WHERE nhr.nagios_server_id IN ($pollersSearch)
AND sgr.host_host_id = nhr.host_host_id
) AS subtable ON log_action.object_id = subtable.servicegroup_id
Expand All @@ -1116,7 +1116,7 @@ function getChangeState(array $pollers): array
SELECT instance_id, COUNT(*) as num_logs, MAX(action_log_date) as action_log_date FROM log_action
INNER JOIN (
SELECT nhr.nagios_server_id as instance_id, hostgroup_hg_id as hostgroup_id
FROM {$conf_centreon['db']}.hostgroup_relation hr, {$conf_centreon['db']}.ns_host_relation nhr
FROM `{$conf_centreon['db']}`.hostgroup_relation hr, `{$conf_centreon['db']}`.ns_host_relation nhr
WHERE nhr.nagios_server_id IN ($pollersSearch)
AND hr.host_host_id = nhr.host_host_id
) AS subtable ON log_action.object_id = subtable.hostgroup_id
Expand Down Expand Up @@ -1176,7 +1176,7 @@ function checkChangeState(int $poller_id, int $last_restart): bool
)
OR object_id IN (
SELECT host_host_id
FROM {$conf_centreon['db']}.ns_host_relation
FROM `{$conf_centreon['db']}`.ns_host_relation`
WHERE nagios_server_id = $poller_id
)
)
Expand All @@ -1194,7 +1194,7 @@ function checkChangeState(int $poller_id, int $last_restart): bool
)
OR object_id IN (
SELECT service_service_id
FROM {$conf_centreon['db']}.ns_host_relation nhr, {$conf_centreon['db']}.host_service_relation hsr
FROM `{$conf_centreon['db']}`.ns_host_relation nhr, `{$conf_centreon['db']}`.host_service_relation hsr
WHERE nagios_server_id = $poller_id
AND hsr.host_host_id = nhr.host_host_id
)
Expand All @@ -1214,7 +1214,7 @@ function checkChangeState(int $poller_id, int $last_restart): bool
)
OR object_id IN (
SELECT DISTINCT servicegroup_sg_id
FROM {$conf_centreon['db']}.servicegroup_relation sgr, {$conf_centreon['db']}.ns_host_relation nhr
FROM `{$conf_centreon['db']}`.servicegroup_relation sgr, `{$conf_centreon['db']}`.ns_host_relation nhr
WHERE sgr.host_host_id = nhr.host_host_id
AND nhr.nagios_server_id = $poller_id
)
Expand All @@ -1234,7 +1234,7 @@ function checkChangeState(int $poller_id, int $last_restart): bool
)
OR object_id IN (
SELECT DISTINCT hr.hostgroup_hg_id
FROM {$conf_centreon['db']}.hostgroup_relation hr, {$conf_centreon['db']}.ns_host_relation nhr
FROM `{$conf_centreon['db']}`.hostgroup_relation hr, `{$conf_centreon['db']}`.ns_host_relation nhr
WHERE hr.host_host_id = nhr.host_host_id
AND nhr.nagios_server_id = $poller_id
)
Expand Down