From 80130158d4f4baa47cf1212cf28da1dc84b9d096 Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Fri, 14 May 2010 07:20:05 -0700 Subject: Bug 556731 - Make Bugzilla::Milestone, Bugzilla::Version, and Bugzilla::Component use VALIDATOR_DEPENDENCIES instead of UPDATE_VALIDATORS r=LpSolit, a=LpSolit --- Bugzilla/Version.pm | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'Bugzilla/Version.pm') diff --git a/Bugzilla/Version.pm b/Bugzilla/Version.pm index 1c96003f1..e40a022c4 100644 --- a/Bugzilla/Version.pm +++ b/Bugzilla/Version.pm @@ -26,6 +26,8 @@ use Bugzilla::Install::Util qw(vers_cmp); use Bugzilla::Util; use Bugzilla::Error; +use Scalar::Util qw(blessed); + ################################ ##### Initialization ##### ################################ @@ -45,7 +47,7 @@ use constant DB_COLUMNS => qw( ); use constant REQUIRED_CREATE_FIELDS => qw( - name + value product ); @@ -55,10 +57,11 @@ use constant UPDATE_COLUMNS => qw( use constant VALIDATORS => { product => \&_check_product, + value => \&_check_value, }; -use constant UPDATE_VALIDATORS => { - value => \&_check_value, +use constant VALIDATOR_DEPENDENCIES => { + value => ['product'], }; ################################ @@ -103,12 +106,8 @@ sub new_from_list { 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->{value} = $class->_check_value($params->{name}, $product); - delete $params->{name}; - return $params; } @@ -171,14 +170,14 @@ sub product { sub set_name { $_[0]->set('value', $_[1]); } sub _check_value { - my ($invocant, $name, $product) = @_; + my ($invocant, $name, undef, $params) = @_; + my $product = blessed($invocant) ? $invocant->product : $params->{product}; $name = trim($name); $name || ThrowUserError('version_blank_name'); # Remove unprintable characters $name = clean_text($name); - $product = $invocant->product if (ref $invocant); my $version = new Bugzilla::Version({ product => $product, name => $name }); if ($version && (!ref $invocant || $version->id != $invocant->id)) { ThrowUserError('version_already_exists', { name => $version->name, @@ -211,7 +210,7 @@ Bugzilla::Version - Bugzilla product version class. my $product = $version->product; my $version = Bugzilla::Version->create( - { name => $name, product => $product }); + { value => $name, product => $product }); $version->set_name($new_name); $version->update(); -- cgit v1.2.3-24-g4f1b