From 4a0e946fb30212c232c6651a47e057d6cc602a1d Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Thu, 26 Jun 2008 06:00:05 +0000 Subject: Bug 440609 – Implement Bugzilla::Bug->check for use instead of ValidateBugID and use it in one file Patch By Max Kanat-Alexander r=LpSolit, a=LpSolit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bugzilla/Bug.pm | 9 +++++++++ Bugzilla/WebService/Bug.pm | 9 +++------ 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index ec603e2b2..2335d0caa 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -272,6 +272,15 @@ sub new { return $self; } +sub check { + my $class = shift; + # XXX At some point we will eliminate ValidateBugID and make this + # method more efficient. + ValidateBugID(@_); + my $self = $class->new(@_); + return $self; +} + # Docs for create() (there's no POD in this file yet, but we very # much need this documented right now): # diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index 9463bce73..dd866a67b 100755 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -75,8 +75,7 @@ sub get { my @return; foreach my $bug_id (@$ids) { - ValidateBugID($bug_id); - my $bug = new Bugzilla::Bug($bug_id); + my $bug = Bugzilla::Bug->check($bug_id); # Timetracking fields are deleted if the user doesn't belong to # the corresponding group. @@ -247,14 +246,12 @@ sub add_comment { # Check parameters defined $params->{id} - || ThrowCodeError('param_required', { param => 'id' }); - ValidateBugID($params->{id}); - + || ThrowCodeError('param_required', { param => 'id' }); my $comment = $params->{comment}; defined $comment || ThrowCodeError('param_required', { param => 'comment' }); - my $bug = new Bugzilla::Bug($params->{id}); + my $bug = Bugzilla::Bug->check($params->{id}); Bugzilla->user->can_edit_product($bug->product_id) || ThrowUserError("product_edit_denied", {product => $bug->product}); -- cgit v1.2.3-24-g4f1b