Proposal for Abstraction Layer for Modifications in Bug.pm
Max Kanat-Alexander
mkanat at kerio.com
Fri Jul 2 23:26:37 UTC 2004
> - Most of the code from post_bug.cgi that sets the fields of a new bug
> according to the form fields should be moved in a new routine, say
> Bugzilla::Bug::new_bug(), which shall be independent of the CGI data
> structure.
Instead of this, I would highly recommend a *private* constructor that
is not exposed as an API element, and a public "create" function, that
initializes the bug in the DB. The constructor should only make the bug
in RAM as an object; putting the thing into the DB or modifying the DB
in any way should be a separate "static factory method."
> - There should be a few routines for changing the content of a bug (to be used
> by process_bug.cgi and attachment.cgi):
>
> * Bugzilla::Bug::add_attachment() for adding a new attachment
>
> * Bugzilla::Bug::add_comment() for adding a new comment
>
> * Bugzilla::Bug::set_flag() for setting flags, obviously
>
> * Bugzilla::Bug::set_field() for changing values of the bug table (roughly)
That would be great. Those all sound perfect. The interesting
discussion, of course, is what the parameters should be. If I have a bug
with a lot of fields, I will probably also want a convenience function
that takes an array of hashes that contain field names and their values,
so I can just stick them all in at once (and quickly).
I think that set_field will be the most difficult -- setting some
fields has a side effect. For example, the syntax for adding a CC might
warrant its own function, since I can simultaneously add and remove CCs.
(True, I could just have a function that takes the new setting of all
the addresses; I suppose that wouldn't be so bad. I feel like there are
bad things lurking in that solution that I can't think of, though.)
Oh, you could probably also use a get_ version for all of these.
> - As doing an UPDATE for each single change would be kind of slow,
> Bugzilla::Bug should remember the changes and Bugzilla::Bug::commit() has to
> be called to issue an UPDATE.
SELECT should probably work in the same sense, if we have the get_
functions.
> - Authorization, e.g. CheckCanChangeField from process_bug.cgi, would also be
> part of Bug.pm.
I was thinking the same thing.
-Max
More information about the developers
mailing list