From 8705d693875ea5f56c6d2e84d23462013faaf414 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Sat, 10 Mar 2007 20:46:06 +0000 Subject: Bug 372700: Make Bugzilla::Bug do bug updating for moving in process_bug.cgi Patch By Max Kanat-Alexander r=LpSolit, a=LpSolit --- Bugzilla/Object.pm | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'Bugzilla/Object.pm') diff --git a/Bugzilla/Object.pm b/Bugzilla/Object.pm index ae4fbeebf..6775d4719 100644 --- a/Bugzilla/Object.pm +++ b/Bugzilla/Object.pm @@ -30,6 +30,8 @@ use constant NAME_FIELD => 'name'; use constant ID_FIELD => 'id'; use constant LIST_ORDER => NAME_FIELD; +use constant UPDATE_VALIDATORS => {}; + ############################### #### Initialization #### ############################### @@ -136,8 +138,8 @@ sub new_from_list { #### Accessors ###### ############################### -sub id { return $_[0]->{'id'}; } -sub name { return $_[0]->{'name'}; } +sub id { return $_[0]->{$_[0]->ID_FIELD}; } +sub name { return $_[0]->{$_[0]->NAME_FIELD}; } ############################### #### Methods #### @@ -153,9 +155,9 @@ sub set { superclass => __PACKAGE__, function => 'Bugzilla::Object->set' }); - my $validators = $self->VALIDATORS; - if (exists $validators->{$field}) { - my $validator = $validators->{$field}; + my %validators = (%{$self->VALIDATORS}, %{$self->UPDATE_VALIDATORS}); + if (exists $validators{$field}) { + my $validator = $validators{$field}; $value = $self->$validator($value, $field); } @@ -374,6 +376,14 @@ These functions should call L if they fail. The validator must return the validated value. +=item C + +This is just like L, but these validators are called only +when updating an object, not when creating it. Any validator that appears +here must not appear in L. + +L has good examples in its code of when to use this. + =item C A list of columns to update when L is called. -- cgit v1.2.3-24-g4f1b