From c93887f249fa25405aad68c56995cdcd2efc1e91 Mon Sep 17 00:00:00 2001 From: Max Kanat-Alexander Date: Mon, 13 Dec 2010 12:54:20 -0800 Subject: Bug 617477: Fix numerous consistency and behavior issues surroudning Bug.update and Bugzilla::Bug. See https://bugzilla.mozilla.org/show_bug.cgi?id=617477#c2 for details. r=LpSolit, a=LpSolit --- Bugzilla/Comment.pm | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'Bugzilla/Comment.pm') diff --git a/Bugzilla/Comment.pm b/Bugzilla/Comment.pm index 7b9e257df..f3628ddb1 100644 --- a/Bugzilla/Comment.pm +++ b/Bugzilla/Comment.pm @@ -77,7 +77,7 @@ use constant VALIDATORS => { use constant VALIDATOR_DEPENDENCIES => { extra_data => ['type'], bug_id => ['who'], - work_time => ['who'], + work_time => ['who', 'bug_id'], isprivate => ['who'], }; @@ -180,6 +180,17 @@ sub set_extra_data { $_[0]->set('extra_data', $_[1]); } # Validators # ############## +sub run_create_validators { + my $self = shift; + my $params = $self->SUPER::run_create_validators(@_); + # Sometimes this run_create_validators is called with parameters that + # skip bug_id validation, so it might not exist in the resulting hash. + if (defined $params->{bug_id}) { + $params->{bug_id} = $params->{bug_id}->id; + } + return $params; +} + sub _check_extra_data { my ($invocant, $extra_data, undef, $params) = @_; my $type = blessed($invocant) ? $invocant->type : $params->{type}; @@ -246,7 +257,7 @@ sub _check_bug_id { $bug->check_can_change_field('longdesc', 0, 1, \$privs) || ThrowUserError('illegal_change', { field => 'longdesc', privs => $privs }); - return $bug->id; + return $bug; } sub _check_who { @@ -276,7 +287,12 @@ sub _check_work_time { # Call down to Bugzilla::Object, letting it know negative # values are ok - return $invocant->check_time( $value_in, $field, $params, 1); + my $time = $invocant->check_time($value_in, $field, $params, 1); + my $privs; + $params->{bug_id}->check_can_change_field('work_time', 0, $time, \$privs) + || ThrowUserError('illegal_change', + { field => 'work_time', privs => $privs }); + return $time; } sub _check_thetext { -- cgit v1.2.3-24-g4f1b