From 9035629755f4c20b7e8c974efd696f09aae981c8 Mon Sep 17 00:00:00 2001 From: Dave Lawrence Date: Thu, 17 Jan 2013 11:29:07 -0500 Subject: Bug 752946 - Moving a bug into another product lists inactive components, milestones and versions r/a=LpSolit --- Bugzilla/Bug.pm | 28 ++++++++++++++++++------- template/en/default/global/user-error.html.tmpl | 5 +++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index e47b05779..f694d0621 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -1462,8 +1462,13 @@ sub _check_component { $name || ThrowUserError("require_component"); my $product = blessed($invocant) ? $invocant->product_obj : $params->{product}; - my $obj = Bugzilla::Component->check({ product => $product, name => $name }); - return $obj; + my $old_comp = blessed($invocant) ? $invocant->component + : $params->{component}; + my $object = Bugzilla::Component->check({ product => $product, name => $name }); + if ($object->name ne $old_comp && !$object->is_active) { + ThrowUserError('value_inactive', { class => ref($object), value => $name }); + } + return $object; } sub _check_creation_ts { @@ -1905,10 +1910,15 @@ sub _check_target_milestone { my ($invocant, $target, undef, $params) = @_; my $product = blessed($invocant) ? $invocant->product_obj : $params->{product}; + my $old_target = blessed($invocant) ? $invocant->target_milestone + : $params->{target_milestone}; $target = trim($target); $target = $product->default_milestone if !defined $target; my $object = Bugzilla::Milestone->check( { product => $product, name => $target }); + if ($object->name ne $old_target && !$object->is_active) { + ThrowUserError('value_inactive', { class => ref($object), value => $target }); + } return $object->name; } @@ -1931,8 +1941,12 @@ sub _check_version { $version = trim($version); my $product = blessed($invocant) ? $invocant->product_obj : $params->{product}; - my $object = - Bugzilla::Version->check({ product => $product, name => $version }); + my $old_vers = blessed($invocant) ? $invocant->version + : $params->{version}; + my $object = Bugzilla::Version->check({ product => $product, name => $version }); + if ($object->name ne $old_vers && !$object->is_active) { + ThrowUserError('value_inactive', { class => ref($object), value => $version }); + } return $object->name; } @@ -2467,9 +2481,9 @@ sub _set_product { milestone => $milestone_ok ? $self->target_milestone : $product->default_milestone }; - $vars{components} = [map { $_->name } @{$product->components}]; - $vars{milestones} = [map { $_->name } @{$product->milestones}]; - $vars{versions} = [map { $_->name } @{$product->versions}]; + $vars{components} = [map { $_->name } grep($_->is_active, @{$product->components})]; + $vars{milestones} = [map { $_->name } grep($_->is_active, @{$product->milestones})]; + $vars{versions} = [map { $_->name } grep($_->is_active, @{$product->versions})]; } if (!$verified) { diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index 4269d693d..2341cd58f 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -1639,6 +1639,11 @@ [% title = "Unknown Tab" %] [% current_tab_name FILTER html %] is not a legal tab name. + [% ELSIF error == "value_inactive" %] + [% title = "Value is Not Active" %] + [% type = BLOCK %][% INCLUDE object_name class = class %][% END %] + The [% type FILTER html %] value '[% value FILTER html %]' is not active. + [% ELSIF error == "version_already_exists" %] [% title = "Version Already Exists" %] [% admindocslinks = {'versions.html' => 'Administering versions'} %] -- cgit v1.2.3-24-g4f1b From 5681c71471fad4081a3b8f620a8f586e0a35a6d8 Mon Sep 17 00:00:00 2001 From: Dave Lawrence Date: Thu, 17 Jan 2013 12:49:28 -0500 Subject: Bug 752946 - Fixed uninitialized error --- Bugzilla/Bug.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index f694d0621..c557930b9 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -1916,7 +1916,7 @@ sub _check_target_milestone { $target = $product->default_milestone if !defined $target; my $object = Bugzilla::Milestone->check( { product => $product, name => $target }); - if ($object->name ne $old_target && !$object->is_active) { + if ($old_target && $object->name ne $old_target && !$object->is_active) { ThrowUserError('value_inactive', { class => ref($object), value => $target }); } return $object->name; -- cgit v1.2.3-24-g4f1b From 8cd4a05a712a3513ae37ced423b7cabdf1730b30 Mon Sep 17 00:00:00 2001 From: Simon Green Date: Sat, 16 Feb 2013 22:58:00 +0100 Subject: Bug 840824: It is possible to create a new bug with a non active target milestone, version or component r/a=LpSolit --- Bugzilla/Bug.pm | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index c557930b9..9610acb7b 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -1462,8 +1462,7 @@ sub _check_component { $name || ThrowUserError("require_component"); my $product = blessed($invocant) ? $invocant->product_obj : $params->{product}; - my $old_comp = blessed($invocant) ? $invocant->component - : $params->{component}; + my $old_comp = blessed($invocant) ? $invocant->component : ''; my $object = Bugzilla::Component->check({ product => $product, name => $name }); if ($object->name ne $old_comp && !$object->is_active) { ThrowUserError('value_inactive', { class => ref($object), value => $name }); @@ -1910,8 +1909,7 @@ sub _check_target_milestone { my ($invocant, $target, undef, $params) = @_; my $product = blessed($invocant) ? $invocant->product_obj : $params->{product}; - my $old_target = blessed($invocant) ? $invocant->target_milestone - : $params->{target_milestone}; + my $old_target = blessed($invocant) ? $invocant->target_milestone : ''; $target = trim($target); $target = $product->default_milestone if !defined $target; my $object = Bugzilla::Milestone->check( @@ -1941,8 +1939,7 @@ sub _check_version { $version = trim($version); my $product = blessed($invocant) ? $invocant->product_obj : $params->{product}; - my $old_vers = blessed($invocant) ? $invocant->version - : $params->{version}; + my $old_vers = blessed($invocant) ? $invocant->version : ''; my $object = Bugzilla::Version->check({ product => $product, name => $version }); if ($object->name ne $old_vers && !$object->is_active) { ThrowUserError('value_inactive', { class => ref($object), value => $version }); -- cgit v1.2.3-24-g4f1b From e3d3e70335676218800c30a3761c32f7c1887e39 Mon Sep 17 00:00:00 2001 From: Matt Tyson Date: Sun, 17 Feb 2013 02:19:08 +0100 Subject: Bug 839950: Cannot search by Change History on multi-select fields r/a=LpSolit --- Bugzilla/Bug.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 9610acb7b..cad024bbd 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -3650,9 +3650,13 @@ sub bug_alias_to_id { # Subroutines ##################################################################### -# Represents which fields from the bugs table are handled by process_bug.cgi. +# Returns a list of currently active and editable bug fields, +# including multi-select fields. sub editable_bug_fields { my @fields = Bugzilla->dbh->bz_table_columns('bugs'); + # Add multi-select fields + push(@fields, map { $_->name } @{Bugzilla->fields({obsolete => 0, + type => FIELD_TYPE_MULTI_SELECT})}); # Obsolete custom fields are not editable. my @obsolete_fields = @{ Bugzilla->fields({obsolete => 1, custom => 1}) }; @obsolete_fields = map { $_->name } @obsolete_fields; @@ -3660,7 +3664,7 @@ sub editable_bug_fields { "lastdiffed", @obsolete_fields) { my $location = firstidx { $_ eq $remove } @fields; - # Custom multi-select fields are not stored in the bugs table. + # Ensure field exists before attempting to remove it. splice(@fields, $location, 1) if ($location > -1); } # Sorted because the old @::log_columns variable, which this replaces, -- cgit v1.2.3-24-g4f1b