From: Frédéric Buclin Date: Mon, 5 Jan 2015 18:30:57 +0000 (+0100) Subject: Bug 1085182: Bugzilla::Bug->check must check that a bug ID is defined when it gets... X-Git-Tag: bugzilla-4.4.7~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9e8c5571d3e38a69ccaa8f9b3a68dcd0f866c2d8;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 d0e8f462b0..b390c12d46 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -354,14 +354,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. - $id = trim($id); - my $self = $class->new($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}) { # For error messages, use the id that was returned by new(), because