-
Notifications
You must be signed in to change notification settings - Fork 209
Fix Command Inheritance not shown #3007 #3009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
c3dbcd1
ff1cc96
54ee066
c6311f0
4db416e
d321bed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -44,6 +44,7 @@ public function getLinks() | |||||||||||||||||||||||||
| 'host' => ['check_command', 'event_command'], | ||||||||||||||||||||||||||
| 'service' => ['check_command', 'event_command'], | ||||||||||||||||||||||||||
| 'notification' => ['command'], | ||||||||||||||||||||||||||
| 'command' => ['command'], | ||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||
| $types = [ | ||||||||||||||||||||||||||
| 'host' => [ | ||||||||||||||||||||||||||
|
|
@@ -60,6 +61,10 @@ public function getLinks() | |||||||||||||||||||||||||
| 'template' => $this->translate('%d Notification Template(s)'), | ||||||||||||||||||||||||||
| 'apply' => $this->translate('%d Notification Apply Rule(s)'), | ||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||
| 'command' => [ | ||||||||||||||||||||||||||
| 'object' => $this->translate('%d Commands(s)'), | ||||||||||||||||||||||||||
| 'template' => $this->translate('%d Command Templates(s)'), | ||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| $urlSuffix = [ | ||||||||||||||||||||||||||
|
|
@@ -93,10 +98,21 @@ protected function fetchFor($table, $rels, $objectTypes) | |||||||||||||||||||||||||
| foreach ($objectTypes as $type) { | ||||||||||||||||||||||||||
| $columns[$type] = "COALESCE(SUM(CASE WHEN object_type = '$type' THEN 1 ELSE 0 END), 0)"; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| $query = $this->db->select()->from("icinga_$table", $columns); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| foreach ($rels as $rel) { | ||||||||||||||||||||||||||
| $query->orWhere("{$rel}_id = ?", $id); | ||||||||||||||||||||||||||
| if ($table === "command") { | ||||||||||||||||||||||||||
| $query = $this->db->select()->from(array('c' => 'icinga_' . $table), $columns)->join(array('ici' => 'icinga_command_inheritance'), | ||||||||||||||||||||||||||
| 'ici.command_id = c.id', | ||||||||||||||||||||||||||
| array()); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| foreach ($rels as $rel) { | ||||||||||||||||||||||||||
| $query->orWhere("parent_{$rel}_id = ?", $id); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+103
to
+109
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
IMO, you could rewrite the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems not to be resolved
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this would render the $rels var useless, and might break something else
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Or you could do the below, where you add the join and the filter to the query only if the table is 'command', and everything remains same. This solution also results in minimal changes to the existing code. You should still give empty array for command ( $query = $this->db->select()->from(['c' => "icinga_$table"], $columns);
if ($table === "command") {
$query->join(
['ici' => 'icinga_command_inheritance'],
'ici.command_id = c.id',
[]
)->where('ici.parent_command_id = ?', $id);
}
foreach ($rels as $rel) {
$query->orWhere("{$rel}_id = ?", $id);
} |
||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||
| $query = $this->db->select()->from("icinga_$table", $columns); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| foreach ($rels as $rel) { | ||||||||||||||||||||||||||
| $query->orWhere("{$rel}_id = ?", $id); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| return $this->db->fetchRow($query); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be an empty array, as this is basically used to build the command id column for the table to filter the objects using the corresponding command.