]> granicus.if.org Git - icinga2/commitdiff
ido: Fix UQ violation in comments with host's hostcheck duplicated service comments
authorMichael Friedrich <michael.friedrich@netways.de>
Wed, 7 Aug 2013 17:03:22 +0000 (19:03 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Wed, 7 Aug 2013 17:03:22 +0000 (19:03 +0200)
refs #4380

lib/ido/servicedbobject.cpp

index b31d90fecacbd138d0ad8cde9e14bf54619d8a5a..30042bca92289c26eac5f1505ff33a317201ad8d 100644 (file)
@@ -330,16 +330,22 @@ void ServiceDbObject::AddCommentByType(DynamicObject::Ptr const& object, Diction
        if (object->GetType() == DynamicType::GetByName("Host")) {
                fields1->Set("comment_type", 2);
                fields1->Set("object_id", static_pointer_cast<Host>(object));
+               /* this is obviously bullshit, but otherwise we would hit
+                * the unique constraint on the table for the same service
+                * comment. dynamically incremented/decremented numbers as
+                * unique constraint - wtf?
+                */
+               fields1->Set("internal_comment_id", 0);
        } else if (object->GetType() == DynamicType::GetByName("Service")) {
                fields1->Set("comment_type", 1);
                fields1->Set("object_id", static_pointer_cast<Service>(object));
+               fields1->Set("internal_comment_id", comment->Get("legacy_id"));
        } else {
                Log(LogDebug, "ido", "unknown object type for adding comment.");
                return;
        }
 
-       fields1->Set("comment_time", DbValue::FromTimestamp(Utility::GetTime()));
-       fields1->Set("internal_comment_id", comment->Get("legacy_id")); /* not sure if that's accurate? */
+       fields1->Set("comment_time", DbValue::FromTimestamp(entry_time)); /* same as entry_time */
        fields1->Set("author_name", comment->Get("author"));
        fields1->Set("comment_data", comment->Get("text"));
        fields1->Set("is_persistent", 1);