Commit 5151736b authored by Pami Ketolainen's avatar Pami Ketolainen Committed by Frédéric Buclin

Bug 782210: If a custom field depends on a product, component or classification,…

Bug 782210: If a custom field depends on a product, component or classification, the "mandatory" bit is ignored on bug creation r/a=LpSolit
parent c3b6bc6e
...@@ -747,6 +747,17 @@ sub run_create_validators { ...@@ -747,6 +747,17 @@ sub run_create_validators {
my $class = shift; my $class = shift;
my $params = $class->SUPER::run_create_validators(@_); 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}; my $product = delete $params->{product};
$params->{product_id} = $product->id; $params->{product_id} = $product->id;
my $component = delete $params->{component}; my $component = delete $params->{component};
...@@ -766,18 +777,11 @@ sub run_create_validators { ...@@ -766,18 +777,11 @@ sub run_create_validators {
# You can't set these fields. # You can't set these fields.
delete $params->{lastdiffed}; delete $params->{lastdiffed};
delete $params->{bug_id}; delete $params->{bug_id};
delete $params->{classification};
Bugzilla::Hook::process('bug_end_of_create_validators', Bugzilla::Hook::process('bug_end_of_create_validators',
{ params => $params }); { 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 # 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 # _check_dependencies to avoid running it twice for both blocked
# and dependson. # and dependson.
......
...@@ -171,6 +171,7 @@ sub is_set_on_bug { ...@@ -171,6 +171,7 @@ sub is_set_on_bug {
# This allows bug/create/create.html.tmpl to pass in a hashref that # This allows bug/create/create.html.tmpl to pass in a hashref that
# looks like a bug object. # looks like a bug object.
my $value = blessed($bug) ? $bug->$field_name : $bug->{$field_name}; my $value = blessed($bug) ? $bug->$field_name : $bug->{$field_name};
$value = $value->name if blessed($value);
return 0 if !defined $value; return 0 if !defined $value;
if ($self->field->type == FIELD_TYPE_BUG_URLS if ($self->field->type == FIELD_TYPE_BUG_URLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment