NAME

Bugzilla::OO - Object Oriented interface to Bugzilla's bug database


SYNOPSIS

        use Bugzilla::OO;
        # Log in as user@example.com
        my $session = Bugzilla::OO->new( 'user@example.com' );
        # Close out bug 471
        my $bug = $session->get_bug( 471 );
        $bug->add_comment( "This bug is fixed" );
        $bug->set_assigned_to( 'user2@example.com' );
        $bug->set_status( 'RESOLVED' );
        $bug->set_resolution( 'FIXED' );
        $bug->send_mail();


DESCRIPTION

The Bugzilla::Bug object is very difficult to work with outside of the web server tree. It doesn't give easy access to the database fields, requiring most users to write their own raw SQL commands. This is a bad thing, since it exposes far more of the database than the users should know about.

Additionally, there are many operations that requiring multiple tables to be updated. If the user doesn't know that the activity log must be updated when the status field is changed, well, then you lose that data. These object methods keep everything in sync so that you do not need to know about the multiple phases of the operations.

This package encapsulates many common bug operations (setting fields, marking duplicates, closing bugs, etc). It doesn't do all of them yet, but it is still a work in progress.


Session Methods

new
Construct a session object as the specified user. Returns undef if the user id does not exist

get_bug
Constructs a Bugzilla::OO::Bug object from the database based on the bug id. If the bug is not numeric, then it will look up by alias. Returns undef if no such bug exists.

query
Internal method to execute a simple query on the database returning an array of the row.

execute
Internal method to run a stored statement against the database. Statements are stored in the %queries hash table as strings until they are used for the first time, at which point they will be compiled with DBI::prepare to speed up future executions.


Bug Object Methods

The Bug object is a subclass in the Bugzilla::OO tree that has the methods for dealing with bugs.

set_time_stamp
Sets the time stamp for operations on the Bug. This is set to the time that the bug is retrieved by get_bug_by_id or get_bug_by_alias, so you should not have to call it again unless you want to set the time to something else.

add_comment
Add a comment to the bug.

add_attachment
Add an attachment to the bug. We should be able to determine if it is a patch automatically, but we depend on the user to tell us.

set_activity
Internal method to do the two-phase update and add to the activity log. This is not one that most users will need to call.

set_assigned_to
Assign this bug to another user.

set_bug_status
Set the status of the bug, as well as update the activity log. This sort of two-phase operation really should be in a transaction.

Allowable status values are:

        ASSIGNED
        CLOSED
        NEW
        REOPENED
        RESOLVED
        UNCONFIRMED
        VERIFIED

set_resolution
Changes the resolution of the bug (not the status). Allowable resolutions are the empty string and one of the following:
        DUPLICATE
        FIXED
        INVALID
        LATER
        MOVED
        REMIND
        WONTFIX
        WORKSFORME

get_duplicate
Return the bug id that this one is marked as a duplicate of, if any.

mark_duplicate
Flag this bug as a duplicate of another bug and add comments to both bugs noting the duplication.


BUGS

Many. This is still a work in progress


SEE ALSO

http://www.bugzilla.org/