From 8f33041e6542f12e6897ef6ed7a67c43a118c504 Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Wed, 23 Jun 2010 17:39:11 -0700 Subject: Bug 572602: Change the way that Bugzilla::Object determines what fields are required for create(). It now assumes that any column that is NOT NULL and has not DEFAULT in the database is required. We also shift the burden of throwing errors about empty values to the validators. This fixes the bug that Bugzilla::Bug->create() wasn't populating default values for fields if they weren't specified in the create() parameters. r=timello, a=mkanat --- Bugzilla/Keyword.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Bugzilla/Keyword.pm') diff --git a/Bugzilla/Keyword.pm b/Bugzilla/Keyword.pm index 882adaf02..e2ecc29e5 100644 --- a/Bugzilla/Keyword.pm +++ b/Bugzilla/Keyword.pm @@ -35,8 +35,6 @@ use constant DB_COLUMNS => qw( use constant DB_TABLE => 'keyworddefs'; -use constant REQUIRED_CREATE_FIELDS => qw(name description); - use constant VALIDATORS => { name => \&_check_name, description => \&_check_description, @@ -106,7 +104,9 @@ sub _check_name { my ($self, $name) = @_; $name = trim($name); - $name eq "" && ThrowUserError("keyword_blank_name"); + if (!defined $name or $name eq "") { + ThrowUserError("keyword_blank_name"); + } if ($name =~ /[\s,]/) { ThrowUserError("keyword_invalid_name"); } @@ -124,7 +124,9 @@ sub _check_name { sub _check_description { my ($self, $desc) = @_; $desc = trim($desc); - $desc eq '' && ThrowUserError("keyword_blank_description"); + if (!defined $desc or $desc eq '') { + ThrowUserError("keyword_blank_description"); + } return $desc; } -- cgit v1.2.3-24-g4f1b