]> 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:13:23 +0000 (12:13 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Tue, 16 Apr 2013 10:13:23 +0000 (12:13 +0200)
r/a=LpSolit

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

index 817bdf3f65b079bd256c2d3dfb355a5f9f1282cf..4d1181315fad39ce753ad4d0acdc52d158f03dad 100644 (file)
@@ -728,6 +728,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};
@@ -747,18 +758,11 @@ sub run_create_validators {
     # You can't set these fields.
     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);
-    }
-
     # And this is not a valid DB field, it's just used as part of 
     # _check_dependencies to avoid running it twice for both blocked 
     # and dependson.
index ad0a61487a5cd1f69cac219d38ffc5e12e23ed3b..b2f1bffd2b4510c7db1c71c4d94d5b78d5e5ee14 100644 (file)
@@ -169,6 +169,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