From: Frédéric Buclin Date: Mon, 5 Jan 2015 18:34:02 +0000 (+0100) Subject: Bug 1085182: Bugzilla::Bug->check must check that a bug ID is defined when it gets... X-Git-Tag: bugzilla-4.0.16~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fde8510f7f6e550ed4dcfcfd4608b09e4d1f7a8;p=thirdparty%2Fbugzilla.git Bug 1085182: Bugzilla::Bug->check must check that a bug ID is defined when it gets a hashref r=dkl a=glob --- 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') {