]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 679547 - Add the ability to create a new bug as a sighting of another bug
authorRobert Webb <rowebb@gmail.com>
Mon, 12 Sep 2011 22:50:07 +0000 (15:50 -0700)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Mon, 12 Sep 2011 22:50:07 +0000 (15:50 -0700)
r=mkanat, a=mkanat

Bugzilla/Bug.pm
Bugzilla/DB/Schema.pm
Bugzilla/Field.pm
Bugzilla/Install/DB.pm
Bugzilla/WebService/Bug.pm
template/en/default/global/user-error.html.tmpl

index 2b526588fffce509ef0310ca19f507b698c8b2ea..f46363566c239d9293a63e78cf9da8ff797bfefc 100644 (file)
@@ -96,6 +96,7 @@ sub DB_COLUMNS {
         estimated_time
         everconfirmed
         lastdiffed
+        master_bug_id
         op_sys
         priority
         product_id
@@ -139,6 +140,7 @@ sub VALIDATORS {
         everconfirmed  => \&Bugzilla::Object::check_boolean,
         groups         => \&_check_groups,
         keywords       => \&_check_keywords,
+        master_bug_id  => \&_check_master_bug_id,
         op_sys         => \&_check_select_field,
         priority       => \&_check_priority,
         product        => \&_check_product,
@@ -228,6 +230,7 @@ sub UPDATE_COLUMNS {
         deadline
         estimated_time
         everconfirmed
+        master_bug_id
         op_sys
         priority
         product_id
@@ -1676,6 +1679,18 @@ sub _check_keywords {
     return [values %keywords];
 }
 
+sub _check_master_bug_id {
+    my ($invocant, $bug_id) = @_;
+    my $bug = Bugzilla::Bug->check_for_edit({ id => $bug_id });
+
+    # Make sure the master bug isn't already a sighting.
+    if (defined $bug->master_bug_id) {
+        ThrowUserError("sighting_of_sighting_not_allowed");
+    }
+
+    return $bug->id;
+}
+
 sub _check_product {
     my ($invocant, $name) = @_;
     $name = trim($name);
@@ -2997,6 +3012,7 @@ sub delta_ts            { return $_[0]->{delta_ts}            }
 sub error               { return $_[0]->{error}               }
 sub everconfirmed       { return $_[0]->{everconfirmed}       }
 sub lastdiffed          { return $_[0]->{lastdiffed}          }
+sub master_bug_id       { return $_[0]->{master_bug_id}       }
 sub op_sys              { return $_[0]->{op_sys}              }
 sub priority            { return $_[0]->{priority}            }
 sub product_id          { return $_[0]->{product_id}          }
@@ -3412,6 +3428,13 @@ sub see_also {
     return $self->{see_also};
 }
 
+sub sightings {
+    my $self = shift;
+    return [] if $self->{'error'};
+    $self->{'sightings'} ||= Bugzilla::Bug->match({master_bug_id => $self->id});
+    return $self->{'sightings'};
+}
+
 sub status {
     my $self = shift;
     return undef if $self->{'error'};
index 33527c367b9420674f9551053281338a4abfc4cf..761510cabda55bf018cb46c0ded939229e9b73ce 100644 (file)
@@ -295,6 +295,9 @@ use constant ABSTRACT_SCHEMA => {
                                     NOTNULL => 1, DEFAULT => '0'},
             deadline            => {TYPE => 'DATETIME'},
             alias               => {TYPE => 'varchar(20)'},
+            master_bug_id       => {TYPE => 'INT3',
+                                    REFERENCES => {TABLE  => 'bugs',
+                                                   COLUMN => 'bug_id'}},
         ],
         INDEXES => [
             bugs_alias_idx            => {FIELDS => ['alias'],
index 6b42cc4afb592e0e19a21f3d74aa4145319009dd..17234e0f7eea771f3c5078454ab40a86b82b3a44 100644 (file)
@@ -259,6 +259,8 @@ use constant DEFAULT_FIELDS => (
     {name => 'see_also',              desc => "See Also",
      type => FIELD_TYPE_BUG_URLS},
     {name => 'tag',                   desc => 'Tags'},
+    {name => 'master_bug_id',         desc => 'Master Bug ID',
+     in_new_bugmail => 1, is_numeric => 1},
 );
 
 ################
index 5ce3c7a4ecc4dd525ba343dd02d95d37f264b70e..e9a3fba4c0f0879b9d9d80a24fe505b00d362672 100644 (file)
@@ -656,6 +656,9 @@ sub update_table_definitions {
     # 2011-06-15 dkl@mozilla.com - Bug 658929
     _migrate_disabledtext_boolean();
 
+    # 2011-08-29 rowebb@gmail.com - Bug 679547
+    $dbh->bz_add_column('bugs', 'master_bug_id', {TYPE => 'INT3'});
+
     ################################################################
     # New --TABLE-- changes should go *** A B O V E *** this point #
     ################################################################
index 63d04bb0bc08755edb4ed46795f82b4554016481..9a68bc42f50105bb067f590b44831e04298a5f12 100644 (file)
@@ -806,6 +806,7 @@ sub _bug_to_hash {
         id               => $self->type('int', $bug->bug_id),
         is_confirmed     => $self->type('boolean', $bug->everconfirmed),
         last_change_time => $self->type('dateTime', $bug->delta_ts),
+        master_bug_id    => $self->type('int', $bug->master_bug_id),
         op_sys           => $self->type('string', $bug->op_sys),
         platform         => $self->type('string', $bug->rep_platform),
         priority         => $self->type('string', $bug->priority),
@@ -867,6 +868,10 @@ sub _bug_to_hash {
                        @{ $bug->see_also };
         $item{'see_also'} = \@see_also;
     }
+    if (filter_wants $params, 'sightings') {
+        my @sightings = map { $self->type('int', $_->id) } @{ $bug->sightings };
+        $item{'sightings'} = \@sightings;
+    }
 
     # And now custom fields
     my @custom_fields = Bugzilla->active_custom_fields;
@@ -1692,6 +1697,11 @@ C<array> of C<string>s. Each keyword that is on this bug.
 
 C<dateTime> When the bug was last changed.
 
+=item C<master_bug_id>
+
+C<int> The unique numeric id of the master bug that this bug is a sighting of. 
+C<undef> if this bug is not a sighting.
+
 =item C<op_sys>
 
 C<string> The name of the operating system that the bug was filed against.
@@ -1735,6 +1745,10 @@ C<array> of C<string>s. The URLs in the See Also field on the bug.
 
 C<string> The current severity of the bug.
 
+=item C<sightings>
+
+C<array> of C<int>s The numeric ids of all this bug's sightings.
+
 =item C<status>
 
 C<string> The current status of the bug.
@@ -1882,6 +1896,9 @@ C<op_sys>, C<platform>, C<qa_contact>, C<remaining_time>, C<see_also>,
 C<target_milestone>, C<update_token>, C<url>, C<version>, C<whiteboard>,
 and all custom fields.
 
+=item In Bugzilla B<5.0> C<sightings> and C<master_bug_id> were added to
+the C<bugs> return value.
+
 =back
 
 
index 7dac2ee55cc52168be293ff720bf61b20bb5e0ed..2d771099f3b2cd707bff06b19b2bac9bfdb915d4 100644 (file)
       [%+ series.name FILTER html %]</em>
       already exists.
     
+  [% ELSIF error == "sighting_of_sighting_not_allowed" %]
+    [% title = "Sightings of Sightings are Not Allowed" %]
+    You may not create a sighting of a sighting or make a master 
+    [% terms.bug %] a sighting of another [% terms.bug %].
+
   [% ELSIF error == "still_unresolved_bugs" %]
     [% title = "Unresolved Dependencies" %]
     [% IF bug_id %]