From 0e307c6482f85f0fdbd277579620d114815959a4 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Wed, 31 Aug 2016 12:57:50 +0200 Subject: [PATCH] IDO: Provide comment name column The Icinga 2 API requires the comment's name when removing the comment. refs #11398 --- .../library/Monitoring/Backend/Ido/Query/CommentQuery.php | 4 ++++ .../library/Monitoring/Backend/Ido/Query/HostcommentQuery.php | 4 ++++ .../Monitoring/Backend/Ido/Query/ServicecommentQuery.php | 4 ++++ modules/monitoring/library/Monitoring/DataView/Comment.php | 1 + .../monitoring/library/Monitoring/DataView/Hostcomment.php | 1 + .../monitoring/library/Monitoring/DataView/Servicecomment.php | 1 + 6 files changed, 15 insertions(+) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentQuery.php index 2fd3fe15f..1d723a0c1 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/CommentQuery.php @@ -23,6 +23,7 @@ class CommentQuery extends IdoQuery 'comment_expiration' => 'c.comment_expiration', 'comment_internal_id' => 'c.comment_internal_id', 'comment_is_persistent' => 'c.comment_is_persistent', + 'comment_name' => 'c.comment_name', 'comment_timestamp' => 'c.comment_timestamp', 'comment_type' => 'c.comment_type', 'instance_name' => 'c.instance_name', @@ -85,6 +86,9 @@ class CommentQuery extends IdoQuery */ protected function joinBaseTables() { + if (version_compare($this->getIdoVersion(), '1.14.0', '<')) { + $this->columnMap['comments']['comment_name'] = '(NULL)'; + } $this->commentQuery = $this->db->select(); $this->select->from( array('c' => $this->commentQuery), diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommentQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommentQuery.php index 056eda400..30cd414ed 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommentQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommentQuery.php @@ -34,6 +34,7 @@ class HostcommentQuery extends IdoQuery 'comment_expiration' => 'CASE c.expires WHEN 1 THEN UNIX_TIMESTAMP(c.expiration_time) ELSE NULL END', 'comment_internal_id' => 'c.internal_comment_id', 'comment_is_persistent' => 'c.is_persistent', + 'comment_name' => 'c.name', 'comment_timestamp' => 'UNIX_TIMESTAMP(c.comment_time)', 'comment_type' => "CASE c.entry_type WHEN 1 THEN 'comment' WHEN 2 THEN 'downtime' WHEN 3 THEN 'flapping' WHEN 4 THEN 'ack' END", 'host' => 'ho.name1 COLLATE latin1_general_ci', @@ -72,6 +73,9 @@ class HostcommentQuery extends IdoQuery */ protected function joinBaseTables() { + if (version_compare($this->getIdoVersion(), '1.14.0', '<')) { + $this->columnMap['comments']['comment_name'] = '(NULL)'; + } $this->select->from( array('c' => $this->prefix . 'comments'), array() diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommentQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommentQuery.php index bebc6b7fd..2225058fd 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommentQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommentQuery.php @@ -34,6 +34,7 @@ class ServicecommentQuery extends IdoQuery 'comment_expiration' => 'CASE c.expires WHEN 1 THEN UNIX_TIMESTAMP(c.expiration_time) ELSE NULL END', 'comment_internal_id' => 'c.internal_comment_id', 'comment_is_persistent' => 'c.is_persistent', + 'comment_name' => 'c.name', 'comment_timestamp' => 'UNIX_TIMESTAMP(c.comment_time)', 'comment_type' => "CASE c.entry_type WHEN 1 THEN 'comment' WHEN 2 THEN 'downtime' WHEN 3 THEN 'flapping' WHEN 4 THEN 'ack' END", 'host' => 'so.name1 COLLATE latin1_general_ci', @@ -77,6 +78,9 @@ class ServicecommentQuery extends IdoQuery */ protected function joinBaseTables() { + if (version_compare($this->getIdoVersion(), '1.14.0', '<')) { + $this->columnMap['comments']['comment_name'] = '(NULL)'; + } $this->select->from( array('c' => $this->prefix . 'comments'), array() diff --git a/modules/monitoring/library/Monitoring/DataView/Comment.php b/modules/monitoring/library/Monitoring/DataView/Comment.php index 56facbec6..3a035bc79 100644 --- a/modules/monitoring/library/Monitoring/DataView/Comment.php +++ b/modules/monitoring/library/Monitoring/DataView/Comment.php @@ -19,6 +19,7 @@ class Comment extends DataView 'comment_expiration', 'comment_internal_id', 'comment_is_persistent', + 'comment_name', 'comment_timestamp', 'comment_type', 'host_display_name', diff --git a/modules/monitoring/library/Monitoring/DataView/Hostcomment.php b/modules/monitoring/library/Monitoring/DataView/Hostcomment.php index 92020abe5..74fc2efef 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hostcomment.php +++ b/modules/monitoring/library/Monitoring/DataView/Hostcomment.php @@ -20,6 +20,7 @@ class Hostcomment extends DataView 'comment_expiration', 'comment_internal_id', 'comment_is_persistent', + 'comment_name', 'comment_timestamp', 'comment_type', 'host_display_name', diff --git a/modules/monitoring/library/Monitoring/DataView/Servicecomment.php b/modules/monitoring/library/Monitoring/DataView/Servicecomment.php index b404955d7..78c133386 100644 --- a/modules/monitoring/library/Monitoring/DataView/Servicecomment.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicecomment.php @@ -20,6 +20,7 @@ class Servicecomment extends DataView 'comment_expiration', 'comment_internal_id', 'comment_is_persistent', + 'comment_name', 'comment_timestamp', 'comment_type', 'host_display_name',