summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Component.pm
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-05-14 16:20:05 +0200
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-05-14 16:20:05 +0200
commit80130158d4f4baa47cf1212cf28da1dc84b9d096 (patch)
treeddedf8e9ae4058e63d08ceb7cbace75a57bd0834 /Bugzilla/Component.pm
parent8bc37c2d851e06b036c8f895582fedd7051b3592 (diff)
downloadbugzilla-80130158d4f4baa47cf1212cf28da1dc84b9d096.tar.gz
bugzilla-80130158d4f4baa47cf1212cf28da1dc84b9d096.tar.xz
Bug 556731 - Make Bugzilla::Milestone, Bugzilla::Version, and
Bugzilla::Component use VALIDATOR_DEPENDENCIES instead of UPDATE_VALIDATORS r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla/Component.pm')
-rw-r--r--Bugzilla/Component.pm25
1 files changed, 10 insertions, 15 deletions
diff --git a/Bugzilla/Component.pm b/Bugzilla/Component.pm
index 5fb911031..a1f5144e5 100644
--- a/Bugzilla/Component.pm
+++ b/Bugzilla/Component.pm
@@ -28,6 +28,8 @@ use Bugzilla::User;
use Bugzilla::FlagType;
use Bugzilla::Series;
+use Scalar::Util qw(blessed);
+
###############################
#### Initialization ####
###############################
@@ -66,10 +68,11 @@ use constant VALIDATORS => {
initialqacontact => \&_check_initialqacontact,
description => \&_check_description,
initial_cc => \&_check_cc_list,
+ name => \&_check_name,
};
-use constant UPDATE_VALIDATORS => {
- name => \&_check_name,
+use constant VALIDATOR_DEPENDENCIES => {
+ name => ['product'],
};
###############################
@@ -116,8 +119,11 @@ sub create {
my $params = $class->run_create_validators(@_);
my $cc_list = delete $params->{initial_cc};
my $create_series = delete $params->{create_series};
+ my $product = delete $params->{product};
+ $params->{product_id} = $product->id;
my $component = $class->insert_create_data($params);
+ $component->{product} = $product;
# We still have to fill the component_cc table.
$component->_update_cc_list($cc_list) if $cc_list;
@@ -129,17 +135,6 @@ sub create {
return $component;
}
-sub run_create_validators {
- my $class = shift;
- my $params = $class->SUPER::run_create_validators(@_);
-
- my $product = delete $params->{product};
- $params->{product_id} = $product->id;
- $params->{name} = $class->_check_name($params->{name}, $product);
-
- return $params;
-}
-
sub update {
my $self = shift;
my $changes = $self->SUPER::update(@_);
@@ -190,7 +185,8 @@ sub remove_from_db {
################################
sub _check_name {
- my ($invocant, $name, $product) = @_;
+ my ($invocant, $name, undef, $params) = @_;
+ my $product = blessed($invocant) ? $invocant->product : $params->{product};
$name = trim($name);
$name || ThrowUserError('component_blank_name');
@@ -199,7 +195,6 @@ sub _check_name {
ThrowUserError('component_name_too_long', {'name' => $name});
}
- $product = $invocant->product if (ref $invocant);
my $component = new Bugzilla::Component({product => $product, name => $name});
if ($component && (!ref $invocant || $component->id != $invocant->id)) {
ThrowUserError('component_already_exists', { name => $component->name,