Simplify code: use helper function that does same

This code was roughly duplicate of what _verifyRequestTypeId() was
already doing.
This commit is contained in:
Bradley M. Kuhn 2015-12-30 03:33:36 -08:00
parent 453caf26bf
commit b03a469338

View file

@ -963,14 +963,8 @@ sub _getOrCreateRequestType($$) {
$params->{requestTypeId} = $self->addRequestType($params->{requestType}); $params->{requestTypeId} = $self->addRequestType($params->{requestType});
} else { } else {
my $id = $params->{requestTypeId}; my $id = $params->{requestTypeId};
die "_getOrCreateRequestType(): called with a non-numeric requestTypeId" die "_getOrCreateRequestType(): invalid requestTypeId, \"$id\""
unless defined $id and looks_like_number($id); unless $self->_verifyRequestTypeId($id);
my $val = $self->dbh()->selectall_hashref("SELECT id FROM request_type WHERE id = " .
$self->dbh->quote($id, 'SQL_INTEGER'), 'id');
die "_getOrCreateRequestType(): given requestTypeId, $id, is invalid"
unless (defined $val and defined $val->{$id});
} }
delete $params->{requestType}; delete $params->{requestType};
} }