Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ivan Ivlev
bugzilla
Commits
c2ebd1bb
Commit
c2ebd1bb
authored
Jan 06, 2008
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 355847: Make the WebService able to add a comment to a bug
Patch By Tsahi Asher <tsahi_75@yahoo.com> r=mkanat, a=mkanat
parent
91d9ad90
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
123 additions
and
3 deletions
+123
-3
Bug.pm
Bugzilla/WebService/Bug.pm
+80
-1
Constants.pm
Bugzilla/WebService/Constants.pm
+2
-0
bz_webservice_demo.pl
contrib/bz_webservice_demo.pl
+41
-2
No files found.
Bugzilla/WebService/Bug.pm
View file @
c2ebd1bb
...
...
@@ -14,6 +14,8 @@
#
# Contributor(s): Marc Schumann <wurblzap@gmail.com>
# Max Kanat-Alexander <mkanat@bugzilla.org>
# Mads Bondo Dydensborg <mbd@dbc.dk>
# Tsahi Asher <tsahi_75@yahoo.com>
package
Bugzilla::WebService::
Bug
;
...
...
@@ -25,7 +27,6 @@ use Bugzilla::Constants;
use
Bugzilla::
Error
;
use
Bugzilla::
Field
;
use
Bugzilla::WebService::
Constants
;
use
Bugzilla::
Util
qw(detaint_natural)
;
use
Bugzilla::
Bug
;
use
Bugzilla::
BugMail
;
use
Bugzilla::
Constants
;
...
...
@@ -177,6 +178,36 @@ sub legal_values {
return
{
values
=>
\
@result
};
}
sub
add_comment
{
my
(
$self
,
$params
)
=
@_
;
#The user must login in order add a comment
Bugzilla
->
login
(
LOGIN_REQUIRED
);
# Check parameters
defined
$params
->
{
id
}
||
ThrowCodeError
(
'param_required'
,
{
param
=>
'id'
});
ValidateBugID
(
$params
->
{
id
});
my
$comment
=
$params
->
{
comment
};
defined
$comment
||
ThrowCodeError
(
'param_required'
,
{
param
=>
'comment'
});
my
$bug
=
new
Bugzilla::
Bug
(
$params
->
{
id
});
Bugzilla
->
user
->
can_edit_product
(
$bug
->
product_id
)
||
ThrowUserError
(
"product_edit_denied"
,
{
product
=>
$bug
->
product
});
# Append comment
$bug
->
add_comment
(
$comment
,
{
isprivate
=>
$params
->
{
private
},
work_time
=>
$params
->
{
work_time
}
});
$bug
->
update
();
# Send mail.
Bugzilla::BugMail::
Send
(
$bug
->
bug_id
,
{
changer
=>
Bugzilla
->
user
->
login
});
return
undef
;
}
1
;
__END__
...
...
@@ -467,5 +498,53 @@ in them. The error message will have more details.
=back
=item C<add_comment> B<EXPERIMENTAL>
=over
=item B<Description>
This allows you to add a comment to a bug in Bugzilla.
=item B<Params>
=over
=item C<id> (int) B<Required> - The id or alias of the bug to append a
comment to.
=item C<comment> (string) B<Required> - The comment to append to the bug.
=item C<private> (boolean) - If set to true, the comment is private, otherwise
it is assumed to be public.
=item C<work_time> (double) - Adds this many hours to the "Hours Worked"
on the bug. If you are not in the time tracking group, this value will
be ignored.
=back
=item B<Errors>
=over
=item 100 (Invalid Bug Alias)
If you specified an alias and either: (a) the Bugzilla you're querying
doesn't support aliases or (b) there is no bug with that alias.
=item 101 (Invalid Bug ID)
The id you specified doesn't exist in the database.
=item 108 (Bug Edit Denied)
You did not have the necessary rights to edit the bug.
=back
=back
=back
Bugzilla/WebService/Constants.pm
View file @
c2ebd1bb
...
...
@@ -75,6 +75,8 @@ use constant WS_ERROR_CODE => {
product_disabled
=>
106
,
# Invalid Summary
require_summary
=>
107
,
# Not authorized to edit the bug
product_edit_denied
=>
108
,
# Authentication errors are usually 300-400.
invalid_username_or_password
=>
300
,
...
...
contrib/bz_webservice_demo.pl
View file @
c2ebd1bb
...
...
@@ -51,6 +51,9 @@ my $bug_id;
my
$product_name
;
my
$create_file_name
;
my
$legal_field_values
;
my
$add_comment
;
my
$private
;
my
$work_time
;
GetOptions
(
'help|h|?'
=>
\
$help
,
'uri=s'
=>
\
$Bugzilla_uri
,
...
...
@@ -60,7 +63,10 @@ GetOptions('help|h|?' => \$help,
'bug_id:s'
=>
\
$bug_id
,
'product_name:s'
=>
\
$product_name
,
'create:s'
=>
\
$create_file_name
,
'field:s'
=>
\
$legal_field_values
'field:s'
=>
\
$legal_field_values
,
'comment:s'
=>
\
$add_comment
,
'private:i'
=>
\
$private
,
'worktime:f'
=>
\
$work_time
)
or
pod2usage
({
'-verbose'
=>
0
,
'-exitval'
=>
1
});
=head1 OPTIONS
...
...
@@ -88,7 +94,7 @@ Bugzilla password. Specify this together with B<--login> in order to log in.
=item --rememberlogin
Gives access to Bugzilla's
“Bugzilla_remember”
option.
Gives access to Bugzilla's
"Bugzilla_remember"
option.
Specify this option while logging in to do the same thing as ticking the
C<Bugzilla_remember> box on Bugilla's log in form.
Don't specify this option to do the same thing as unchecking the box.
...
...
@@ -114,6 +120,20 @@ Pass a field name to get legal values for this field. It must be either a
global select field (such as bug_status, resolution, rep_platform, op_sys,
priority, bug_severity) or a custom select field.
=item --comment
A comment to add to a bug identified by B<--bug_id>. You must also pass a B<--login>
and B<--password> to log in to Bugzilla.
=item --private
An optional non-zero value to specify B<--comment> as private.
=item --worktime
An optional double precision number specifying the work time for B<--comment>.
=back
=head1 DESCRIPTION
...
...
@@ -302,6 +322,25 @@ if ($legal_field_values) {
print
join
(
"\n"
,
@
{
$result
->
{
values
}})
.
"\n"
;
}
=head2 Adding a comment to a bug
Call C<Bug.add_comment> with the bug id, the comment text, and optionally the number
of hours you worked on the bug, and a boolean indicating if the comment is private
or not.
=cut
if
(
$add_comment
)
{
if
(
$bug_id
)
{
$soapresult
=
$proxy
->
call
(
'Bug.add_comment'
,
{
id
=>
$bug_id
,
comment
=>
$add_comment
,
private
=>
$private
,
work_time
=>
$work_time
});
_die_on_fault
(
$soapresult
);
print
"Comment added.\n"
;
}
else
{
print
"A --bug_id must be supplied to add a comment."
;
}
}
=head1 NOTES
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment