]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 782210: If a custom field depends on a product, component or classification...
authorPami Ketolainen <pami.ketolainen@jollamobile.com>
Tue, 16 Apr 2013 10:14:23 +0000 (12:14 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Tue, 16 Apr 2013 10:14:23 +0000 (12:14 +0200)
r/a=LpSolit

Bugzilla/Bug.pm
Bugzilla/Field/ChoiceInterface.pm

index cad024bbd25af7b12a0911a875a760f7129ade2b..7b86ab2a1eea8907f59736332cd6bf100a55d5f7 100644 (file)
@@ -730,6 +730,17 @@ sub run_create_validators {
     my $class  = shift;
     my $params = $class->SUPER::run_create_validators(@_);
 
+    # Add classification for checking mandatory fields which depend on it
+    $params->{classification} = $params->{product}->classification->name;
+
+    my @mandatory_fields = @{ Bugzilla->fields({ is_mandatory => 1,
+                                                 enter_bug    => 1,
+                                                 obsolete     => 0 }) };
+    foreach my $field (@mandatory_fields) {
+        $class->_check_field_is_mandatory($params->{$field->name}, $field,
+                                          $params);
+    }
+
     my $product = delete $params->{product};
     $params->{product_id} = $product->id;
     my $component = delete $params->{component};
@@ -754,18 +765,11 @@ sub run_create_validators {
     delete $params->{resolution};
     delete $params->{lastdiffed};
     delete $params->{bug_id};
+    delete $params->{classification};
 
     Bugzilla::Hook::process('bug_end_of_create_validators',
                             { params => $params });
 
-    my @mandatory_fields = @{ Bugzilla->fields({ is_mandatory => 1,
-                                                 enter_bug    => 1,
-                                                 obsolete     => 0 }) };
-    foreach my $field (@mandatory_fields) {
-        $class->_check_field_is_mandatory($params->{$field->name}, $field,
-                                          $params);
-    }
-
     return $params;
 }
 
index 87354a1036d16af90ee1df1f96f73dd07fa31c0a..3292536d34ca94fe0723bd15beb49befb5090315 100644 (file)
@@ -183,6 +183,7 @@ sub is_set_on_bug {
     # This allows bug/create/create.html.tmpl to pass in a hashref that 
     # looks like a bug object.
     my $value = blessed($bug) ? $bug->$field_name : $bug->{$field_name};
+    $value = $value->name if blessed($value);
     return 0 if !defined $value;
 
     if ($self->field->type == FIELD_TYPE_BUG_URLS