@@ -523,17 +523,14 @@ sub possible_duplicates {
523523 if ($dbh -> FULLTEXT_OR) {
524524 my $joined_terms = join ($dbh -> FULLTEXT_OR, @words );
525525 ($where_sql , $relevance_sql ) =
526- $dbh -> sql_fulltext_search(' bugs_fulltext.short_desc' ,
527- $joined_terms , 1);
526+ $dbh -> sql_fulltext_search(' bugs_fulltext.short_desc' , $joined_terms );
528527 $relevance_sql ||= $where_sql ;
529528 }
530529 else {
531530 my (@where , @relevance );
532- my $count = 0;
533531 foreach my $word (@words ) {
534- $count ++;
535532 my ($term , $rel_term ) = $dbh -> sql_fulltext_search(
536- ' bugs_fulltext.short_desc' , $word , $count );
533+ ' bugs_fulltext.short_desc' , $word );
537534 push (@where , $term );
538535 push (@relevance , $rel_term || $term );
539536 }
@@ -733,6 +730,17 @@ sub run_create_validators {
733730 my $class = shift ;
734731 my $params = $class -> SUPER::run_create_validators(@_ );
735732
733+ # Add classification for checking mandatory fields which depend on it
734+ $params -> {classification } = $params -> {product }-> classification-> name;
735+
736+ my @mandatory_fields = @{ Bugzilla-> fields({ is_mandatory => 1,
737+ enter_bug => 1,
738+ obsolete => 0 }) };
739+ foreach my $field (@mandatory_fields ) {
740+ $class -> _check_field_is_mandatory($params -> {$field -> name}, $field ,
741+ $params );
742+ }
743+
736744 my $product = delete $params -> {product };
737745 $params -> {product_id } = $product -> id;
738746 my $component = delete $params -> {component };
@@ -757,18 +765,11 @@ sub run_create_validators {
757765 delete $params -> {resolution };
758766 delete $params -> {lastdiffed };
759767 delete $params -> {bug_id };
768+ delete $params -> {classification };
760769
761770 Bugzilla::Hook::process(' bug_end_of_create_validators' ,
762771 { params => $params });
763772
764- my @mandatory_fields = @{ Bugzilla-> fields({ is_mandatory => 1,
765- enter_bug => 1,
766- obsolete => 0 }) };
767- foreach my $field (@mandatory_fields ) {
768- $class -> _check_field_is_mandatory($params -> {$field -> name}, $field ,
769- $params );
770- }
771-
772773 return $params ;
773774}
774775
@@ -1371,7 +1372,7 @@ sub _check_bug_status {
13711372 }
13721373
13731374 # Check if a comment is required for this change.
1374- if ($new_status -> comment_required_on_change_from($old_status ) && !$comment )
1375+ if ($new_status -> comment_required_on_change_from($old_status ) && !$comment -> { ' thetext ' } )
13751376 {
13761377 ThrowUserError(' comment_required' , { old => $old_status ,
13771378 new => $new_status });
@@ -1465,8 +1466,12 @@ sub _check_component {
14651466 $name || ThrowUserError(" require_component" );
14661467 my $product = blessed($invocant ) ? $invocant -> product_obj
14671468 : $params -> {product };
1468- my $obj = Bugzilla::Component-> check({ product => $product , name => $name });
1469- return $obj ;
1469+ my $old_comp = blessed($invocant ) ? $invocant -> component : ' ' ;
1470+ my $object = Bugzilla::Component-> check({ product => $product , name => $name });
1471+ if ($object -> name ne $old_comp && !$object -> is_active) {
1472+ ThrowUserError(' value_inactive' , { class => ref ($object ), value => $name });
1473+ }
1474+ return $object ;
14701475}
14711476
14721477sub _check_creation_ts {
@@ -1908,10 +1913,14 @@ sub _check_target_milestone {
19081913 my ($invocant , $target , undef , $params ) = @_ ;
19091914 my $product = blessed($invocant ) ? $invocant -> product_obj
19101915 : $params -> {product };
1916+ my $old_target = blessed($invocant ) ? $invocant -> target_milestone : ' ' ;
19111917 $target = trim($target );
19121918 $target = $product -> default_milestone if !defined $target ;
19131919 my $object = Bugzilla::Milestone-> check(
19141920 { product => $product , name => $target });
1921+ if ($old_target && $object -> name ne $old_target && !$object -> is_active) {
1922+ ThrowUserError(' value_inactive' , { class => ref ($object ), value => $target });
1923+ }
19151924 return $object -> name;
19161925}
19171926
@@ -1934,8 +1943,11 @@ sub _check_version {
19341943 $version = trim($version );
19351944 my $product = blessed($invocant ) ? $invocant -> product_obj
19361945 : $params -> {product };
1937- my $object =
1938- Bugzilla::Version-> check({ product => $product , name => $version });
1946+ my $old_vers = blessed($invocant ) ? $invocant -> version : ' ' ;
1947+ my $object = Bugzilla::Version-> check({ product => $product , name => $version });
1948+ if ($object -> name ne $old_vers && !$object -> is_active) {
1949+ ThrowUserError(' value_inactive' , { class => ref ($object ), value => $version });
1950+ }
19391951 return $object -> name;
19401952}
19411953
@@ -1953,6 +1965,12 @@ sub _check_field_is_mandatory {
19531965
19541966 return if !$field -> is_visible_on_bug($params || $invocant );
19551967
1968+ return if ($field -> type == FIELD_TYPE_SINGLE_SELECT
1969+ && scalar @{ get_legal_field_values($field -> name) } == 1);
1970+
1971+ return if ($field -> type == FIELD_TYPE_MULTI_SELECT
1972+ && !scalar @{ get_legal_field_values($field -> name) });
1973+
19561974 if (ref ($value ) eq ' ARRAY' ) {
19571975 $value = join (' ' , @$value );
19581976 }
@@ -2464,9 +2482,9 @@ sub _set_product {
24642482 milestone => $milestone_ok ? $self -> target_milestone
24652483 : $product -> default_milestone
24662484 };
2467- $vars {components } = [map { $_ -> name } @{$product -> components}];
2468- $vars {milestones } = [map { $_ -> name } @{$product -> milestones}];
2469- $vars {versions } = [map { $_ -> name } @{$product -> versions}];
2485+ $vars {components } = [map { $_ -> name } grep ( $_ -> is_active, @{$product -> components}) ];
2486+ $vars {milestones } = [map { $_ -> name } grep ( $_ -> is_active, @{$product -> milestones}) ];
2487+ $vars {versions } = [map { $_ -> name } grep ( $_ -> is_active, @{$product -> versions}) ];
24702488 }
24712489
24722490 if (!$verified ) {
@@ -2872,7 +2890,8 @@ sub add_see_also {
28722890 # ref bug id for sending changes email.
28732891 my $ref_bug = delete $field_values -> {ref_bug };
28742892 if ($class -> isa(' Bugzilla::BugUrl::Bugzilla::Local' )
2875- and !$skip_recursion )
2893+ and !$skip_recursion
2894+ and $ref_bug -> check_can_change_field(' see_also' , ' ' , $self -> id, \$privs ))
28762895 {
28772896 $ref_bug -> add_see_also($self -> id, ' skip_recursion' );
28782897 push @{ $self -> {_update_ref_bugs } }, $ref_bug ;
@@ -2904,12 +2923,15 @@ sub remove_see_also {
29042923 # we need to notify changes for that bug too.
29052924 $removed_bug_url = $removed_bug_url -> [0];
29062925 if (!$skip_recursion and $removed_bug_url
2907- and $removed_bug_url -> isa(' Bugzilla::BugUrl::Bugzilla::Local' ))
2926+ and $removed_bug_url -> isa(' Bugzilla::BugUrl::Bugzilla::Local' )
2927+ and $removed_bug_url -> ref_bug_url)
29082928 {
29092929 my $ref_bug
29102930 = Bugzilla::Bug-> check($removed_bug_url -> ref_bug_url-> bug_id);
29112931
2912- if (Bugzilla-> user-> can_edit_product($ref_bug -> product_id)) {
2932+ if (Bugzilla-> user-> can_edit_product($ref_bug -> product_id)
2933+ and $ref_bug -> check_can_change_field(' see_also' , $self -> id, ' ' , \$privs ))
2934+ {
29132935 my $self_url = $removed_bug_url -> local_uri($self -> id);
29142936 $ref_bug -> remove_see_also($self_url , ' skip_recursion' );
29152937 push @{ $self -> {_update_ref_bugs } }, $ref_bug ;
@@ -3632,17 +3654,21 @@ sub bug_alias_to_id {
36323654# Subroutines
36333655# ####################################################################
36343656
3635- # Represents which fields from the bugs table are handled by process_bug.cgi.
3657+ # Returns a list of currently active and editable bug fields,
3658+ # including multi-select fields.
36363659sub editable_bug_fields {
36373660 my @fields = Bugzilla-> dbh-> bz_table_columns(' bugs' );
3661+ # Add multi-select fields
3662+ push (@fields , map { $_ -> name } @{Bugzilla-> fields({obsolete => 0,
3663+ type => FIELD_TYPE_MULTI_SELECT})});
36383664 # Obsolete custom fields are not editable.
36393665 my @obsolete_fields = @{ Bugzilla-> fields({obsolete => 1, custom => 1}) };
36403666 @obsolete_fields = map { $_ -> name } @obsolete_fields ;
36413667 foreach my $remove (" bug_id" , " reporter" , " creation_ts" , " delta_ts" ,
36423668 " lastdiffed" , @obsolete_fields )
36433669 {
36443670 my $location = firstidx { $_ eq $remove } @fields ;
3645- # Custom multi-select fields are not stored in the bugs table .
3671+ # Ensure field exists before attempting to remove it .
36463672 splice (@fields , $location , 1) if ($location > -1);
36473673 }
36483674 # Sorted because the old @::log_columns variable, which this replaces,
0 commit comments