From 5fde8510f7f6e550ed4dcfcfd4608b09e4d1f7a8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Buclin?= Date: Mon, 5 Jan 2015 19:34:02 +0100 Subject: [PATCH] Bug 1085182: Bugzilla::Bug->check must check that a bug ID is defined when it gets a hashref r=dkl a=glob --- Bugzilla/Bug.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index b57af4d39b..b3931584c2 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -363,16 +363,16 @@ sub new { sub check { my $class = shift; - my ($id, $field) = @_; - - ThrowUserError('improper_bug_id_field_value', { field => $field }) unless defined $id; + my ($param, $field) = @_; # Bugzilla::Bug throws lots of special errors, so we don't call # SUPER::check, we just call our new and do our own checks. - my $self = $class->new(trim($id)); - # For error messages, use the id that was returned by new(), because - # it's cleaned up. - $id = $self->id; + my $id = ref($param) + ? ($param->{id} = trim($param->{id})) + : ($param = trim($param)); + ThrowUserError('improper_bug_id_field_value', { field => $field }) unless defined $id; + + my $self = $class->new($param); if ($self->{error}) { if ($self->{error} eq 'NotFound') { -- 2.47.2