diff options
author | mkanat%bugzilla.org <> | 2007-03-10 21:46:06 +0100 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2007-03-10 21:46:06 +0100 |
commit | 8705d693875ea5f56c6d2e84d23462013faaf414 (patch) | |
tree | f8635829555be5da7574b96e1bb54bc0ce71ccee /Bugzilla/Object.pm | |
parent | 839d66da3f158712fe59bf5fd480df12512f4bf6 (diff) | |
download | bugzilla-8705d693875ea5f56c6d2e84d23462013faaf414.tar.gz bugzilla-8705d693875ea5f56c6d2e84d23462013faaf414.tar.xz |
Bug 372700: Make Bugzilla::Bug do bug updating for moving in process_bug.cgi
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla/Object.pm')
-rw-r--r-- | Bugzilla/Object.pm | 20 |
1 files changed, 15 insertions, 5 deletions
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<Bugzilla::Error/ThrowUserError> if they fail. The validator must return the validated value. +=item C<UPDATE_VALIDATORS> + +This is just like L</VALIDATORS>, but these validators are called only +when updating an object, not when creating it. Any validator that appears +here must not appear in L</VALIDATORS>. + +L<Bugzilla::Bug> has good examples in its code of when to use this. + =item C<UPDATE_COLUMNS> A list of columns to update when L</update> is called. |