Getting latest comment while in bug-end_of_update.pl - Mozilla

This is a discussion on Getting latest comment while in bug-end_of_update.pl - Mozilla ; We're using the bug-end_of_update.pl hook to integrate Bugzilla with a Customer Support system that doesn't include a defect tracking module. We're sending back info about changes to status, deadlines, milestones, etc. but would also like to inlude the the latest ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Getting latest comment while in bug-end_of_update.pl

  1. Getting latest comment while in bug-end_of_update.pl

    We're using the bug-end_of_update.pl hook to integrate Bugzilla with a
    Customer Support system that doesn't include a defect tracking
    module. We're sending back info about changes to status, deadlines,
    milestones, etc. but would also like to inlude the the latest comment,
    particulary if it's changed. I can't see where this info is available
    in the the Bug or Changes hash. Can anyone help with the command I
    would use to retrieve this?

    -Tom

  2. Re: Getting latest comment while in bug-end_of_update.pl

    On May 28, 6:52*pm, Max Kanat-Alexander wrote:
    > Tom Owens wrote:
    > > We're using the bug-end_of_update.pl hook to integrate Bugzilla with a
    > > Customer Support system that doesn't include a defect tracking
    > > module. *We're sending back info about changes to status, deadlines,
    > > milestones, etc. but would also like to inlude the the latest comment,
    > > particulary if it's changed. *I can't see where this info is available
    > > in the the Bug or Changes hash. *Can anyone help with the command I
    > > would use to retrieve this?

    >
    > * * * * $bug->longdescs gets the comments on the bug. If there's a new comment,
    > it will probably be in $bug->{added_comments}, although I think that has
    > a different format than $bug->longdescs. See $bug->add_comment for the
    > code that creates {added_comments}.
    >
    > * * * * -Max
    > --http://www.everythingsolved.com/
    > Competent, Friendly Bugzilla and Perl Services. Everything Else, too.


    I'm afraid I'm not having much luck with either option so far. I'm
    tring to use $bug->{added_comments} but can't seem to dereference
    it.

    This code is in my hook script:
    my $addedcomments = $bug->{added_comments};
    my @lastcomment = @$addedcomments;
    print bugfile "AddedComments: $addedcomments\n";
    print bugfile "LastComment: @lastcomment\n";

    And it prints this result:
    AddedComments: ARRAY(0x273d78c)
    LastComment: HASH(0x27428d4)

    If I try to defeference @lastcomment as a hash, I get this error:
    Can't use string ("1") as a HASH ref while "strict refs" in use

    I tried looking at the code you suggested but I'm new to Perl and all
    I could tell is that it seems to create a hash. I'd really appreciate
    it if you could offer any other insight into my problem.

    Thanks in advance,
    Tom

  3. Re: Getting latest comment while in bug-end_of_update.pl

    On May 29, 10:16*pm, Tom Owens wrote:
    > On May 28, 6:52*pm, Max Kanat-Alexander wrote:
    >
    >
    >
    >
    >
    > > Tom Owens wrote:
    > > > We're using the bug-end_of_update.pl hook to integrate Bugzilla with a
    > > > Customer Support system that doesn't include a defect tracking
    > > > module. *We're sending back info about changes to status, deadlines,
    > > > milestones, etc. but would also like to inlude the the latest comment,
    > > > particulary if it's changed. *I can't see where this info is available
    > > > in the the Bug or Changes hash. *Can anyone help with the command I
    > > > would use to retrieve this?

    >
    > > * * * * $bug->longdescs gets the comments on the bug. If there's a new comment,
    > > it will probably be in $bug->{added_comments}, although I think that has
    > > a different format than $bug->longdescs. See $bug->add_comment for the
    > > code that creates {added_comments}.

    >
    > > * * * * -Max
    > > --http://www.everythingsolved.com/
    > > Competent, Friendly Bugzilla and Perl Services. Everything Else, too.

    >
    > I'm afraid I'm not having much luck with either option so far. I'm
    > tring to use $bug->{added_comments} but can't seem to dereference
    > it.
    >
    > This code is in my hook script:
    > my $addedcomments = $bug->{added_comments};
    > my @lastcomment = @$addedcomments;
    > print bugfile "AddedComments: $addedcomments\n";
    > print bugfile "LastComment: @lastcomment\n";
    >
    > And it prints this result:
    > AddedComments: ARRAY(0x273d78c)
    > LastComment: HASH(0x27428d4)
    >
    > If I try to defeference @lastcomment as a hash, I get this error:
    > Can't use string ("1") as a HASH ref while "strict refs" in use
    >
    > I tried looking at the code you suggested but I'm new to Perl and all
    > I could tell is that it seems to create a hash. *I'd really appreciate
    > it if you could offer any other insight into my problem.
    >
    > Thanks in advance,
    > Tom- Hide quoted text -
    >
    > - Show quoted text -


    I actually figured this out myself by looking at the code again. This
    may not be elegant Perl, but it seems to work.

    This code:
    my $lastcomment = "";
    foreach my $comment (@{$bug->{added_comments} || []}) {
    my @values = values %$comment;
    $lastcomment = @values->[1];
    }
    print bugfile "Last comment: $lastcomment\n";

    Prints this result:
    Last comment: OK, this works!


+ Reply to Thread