[Fwd: Re: [scmbug-users] Error on changing status of bugs with Bugzilla 3.4.x]

Max Kanat-Alexander mkanat at bugzilla.org
Fri Apr 16 09:01:45 UTC 2010


On 04/16/2010 01:48 AM, Yavor Nikolov wrote:
> We're calling this from separate perl application - not as CGI. So I
> believe error_mode is ERROR_MODE_DIE by default in our case.

	Yeah, if you're not running in a web server, you're using
ERROR_MODE_DIE by default.

> Good to know if there are better alternatives. We have a daemon (perl
> application) which is integrating version control systems (e.g.
> Subversion) with Bug-tracking system (Bugzilla).

	Yeah, I know what scmbug is. :-) I just needed to see the code of what
you were doing.

>  - add comment to the bug (extracted from version control system commit
> message)

	I'd suggest doing this via the WebServices--Bug.add_comment.

>  - update bugzilla bug status and resolution; or reassign bug

>         my @ret_list = eval {

	Don't run the whole block of code in an eval--just run the parts that
can throw errors.

>         my $userid = Bugzilla::User::login_to_id( $username );

	You should probably just be doing "my $user = new Bugzilla::User({ name
=> $username }) there.

	You could also do:

	my $user = eval { Bugzilla::User->check($username) };
	error($@) if !$user;

>             my $bug = Bugzilla::Bug->check($bugid);

	Okay, that you can do, but wrap it in an eval and return the error to
the user if there's a problem.

	So you'd want to do something like:

	my $bug = eval { Bugzilla::Bug->check($bugid) };
	error($@) if !$bug;

	Note that error() is a made-up subroutine. I just mean handle the error
however scmbug normally does.

>             $bug->add_comment($comment, {isprivate => 0, work_time => 0,
> type => Bugzilla::Constants->CMT_NORMAL, extra_data => ""} );

	You don't need to specify those extra arguments if they're all at the
defaults.

	This could *theoretically* throw an error, although it's pretty
unlikely. You could put it in an eval if you *really want to*.

>             $bug->update();

	$bug->update() is not generally capable of throwing an error.

>             $dbh->bz_commit_transaction();

	You don't need bz_start_transaction or bz_commit_transaction for this
block, you can get rid of them. $bug->update() will do a transaction itself.

>  - Nor type of error could be easily distinguished (it's just plain text).

	You shouldn't have to distinguish the type of error, in this particular
case, though--just return it to the user.

>  + Recent versions of Perl support object oriented exception handling
> mechanism which sounds better to me.

	No, they don't. There are just various CPAN modules available that
attempt to implement exceptions, and they probably aren't quite as good
as you'd imagine.

> I can't find the link now but I've found some discussion where Kristis
> explained that WebService API was not powerful enough (maybe since the
> scmbug daemon should be able to impersonate as any user without
> requesting version control user to provide a password).

	Well, okay. You could also have scmbug use one Bugzilla user for all of
its changes.

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



More information about the developers mailing list