summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Version.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/Version.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/Version.pm')
-rw-r--r--Bugzilla/Version.pm19
1 files changed, 9 insertions, 10 deletions
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();