diff options
author | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-05-14 07:20:05 -0700 |
---|---|---|
committer | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-05-14 07:20:05 -0700 |
commit | 80130158d4f4baa47cf1212cf28da1dc84b9d096 (patch) | |
tree | ddedf8e9ae4058e63d08ceb7cbace75a57bd0834 /Bugzilla/Milestone.pm | |
parent | 8bc37c2d851e06b036c8f895582fedd7051b3592 (diff) | |
download | bugs-80130158d4f4baa47cf1212cf28da1dc84b9d096.tar bugs-80130158d4f4baa47cf1212cf28da1dc84b9d096.tar.gz bugs-80130158d4f4baa47cf1212cf28da1dc84b9d096.tar.bz2 bugs-80130158d4f4baa47cf1212cf28da1dc84b9d096.tar.xz bugs-80130158d4f4baa47cf1212cf28da1dc84b9d096.zip |
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/Milestone.pm')
-rw-r--r-- | Bugzilla/Milestone.pm | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/Bugzilla/Milestone.pm b/Bugzilla/Milestone.pm index fc44cf1af..fafd14ad0 100644 --- a/Bugzilla/Milestone.pm +++ b/Bugzilla/Milestone.pm @@ -26,6 +26,8 @@ use Bugzilla::Constants; use Bugzilla::Util; use Bugzilla::Error; +use Scalar::Util qw(blessed); + ################################ ##### Initialization ##### ################################ @@ -44,7 +46,7 @@ use constant DB_COLUMNS => qw( ); use constant REQUIRED_CREATE_FIELDS => qw( - name + value product ); @@ -56,10 +58,11 @@ use constant UPDATE_COLUMNS => qw( use constant VALIDATORS => { product => \&_check_product, sortkey => \&_check_sortkey, + value => \&_check_value, }; -use constant UPDATE_VALIDATORS => { - value => \&_check_value, +use constant VALIDATOR_DEPENDENCIES => { + value => ['product'], }; ################################ @@ -94,14 +97,10 @@ sub new { } sub run_create_validators { - my $class = shift; + 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; } @@ -165,7 +164,8 @@ sub remove_from_db { ################################ 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('milestone_blank_name'); @@ -173,7 +173,6 @@ sub _check_value { ThrowUserError('milestone_name_too_long', {name => $name}); } - $product = $invocant->product if (ref $invocant); my $milestone = new Bugzilla::Milestone({product => $product, name => $name}); if ($milestone && (!ref $invocant || $milestone->id != $invocant->id)) { ThrowUserError('milestone_already_exists', { name => $milestone->name, @@ -255,7 +254,7 @@ Bugzilla::Milestone - Bugzilla product milestone class. my $sortkey = $milestone->sortkey; my $milestone = Bugzilla::Milestone->create( - { name => $name, product => $product, sortkey => $sortkey }); + { value => $name, product => $product, sortkey => $sortkey }); $milestone->set_name($new_name); $milestone->set_sortkey($new_sortkey); @@ -361,11 +360,11 @@ Milestone.pm represents a Product Milestone object. =over -=item C<create({name => $name, product => $product, sortkey => $sortkey})> +=item C<create({value => $value, product => $product, sortkey => $sortkey})> Description: Create a new milestone for the given product. - Params: $name - name of the new milestone (string). This name + Params: $value - name of the new milestone (string). This name must be unique within the product. $product - a Bugzilla::Product object. $sortkey - the sortkey of the new milestone (signed integer) |