From: Robert Webb Date: Mon, 12 Sep 2011 22:50:07 +0000 (-0700) Subject: Bug 679547 - Add the ability to create a new bug as a sighting of another bug X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95ad9bcd22f221f788eb3c9997818c7eddef89c6;p=thirdparty%2Fbugzilla.git Bug 679547 - Add the ability to create a new bug as a sighting of another bug r=mkanat, a=mkanat --- diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 2b526588ff..f46363566c 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -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'}; diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm index 33527c367b..761510cabd 100644 --- a/Bugzilla/DB/Schema.pm +++ b/Bugzilla/DB/Schema.pm @@ -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'], diff --git a/Bugzilla/Field.pm b/Bugzilla/Field.pm index 6b42cc4afb..17234e0f7e 100644 --- a/Bugzilla/Field.pm +++ b/Bugzilla/Field.pm @@ -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}, ); ################ diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index 5ce3c7a4ec..e9a3fba4c0 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -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 # ################################################################ diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index 63d04bb0bc..9a68bc42f5 100644 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -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 of Cs. Each keyword that is on this bug. C When the bug was last changed. +=item C + +C The unique numeric id of the master bug that this bug is a sighting of. +C if this bug is not a sighting. + =item C C The name of the operating system that the bug was filed against. @@ -1735,6 +1745,10 @@ C of Cs. The URLs in the See Also field on the bug. C The current severity of the bug. +=item C + +C of Cs The numeric ids of all this bug's sightings. + =item C C The current status of the bug. @@ -1882,6 +1896,9 @@ C, C, C, C, C, C, C, C, C, C, and all custom fields. +=item In Bugzilla B<5.0> C and C were added to +the C return value. + =back diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index 7dac2ee55c..2d771099f3 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -1532,6 +1532,11 @@ [%+ series.name FILTER html %] 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 %]