core/modules/rest/src/RequestHandler.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/modules/rest/src/RequestHandler.php b/core/modules/rest/src/RequestHandler.php index c6430e0..7443537 100644 --- a/core/modules/rest/src/RequestHandler.php +++ b/core/modules/rest/src/RequestHandler.php @@ -143,9 +143,13 @@ protected function getResponseFormat(RouteMatchInterface $route_match, Request $ if (!empty($acceptable_content_type_formats)) { return $acceptable_content_type_formats[0]; } - else { + elseif (!empty($acceptable_request_formats)) { return $acceptable_request_formats[0]; } + // Sometimes, there are no acceptable formats, e.g. DELETE routes. + else { + return NULL; + } } } @@ -174,8 +178,9 @@ public function csrfToken() { * The response from the REST resource. * @param \Symfony\Component\Serializer\SerializerInterface $serializer * The serializer to use. - * @param string $format - * The response format. + * @param string|null $format + * The response format, or NULL in case the response does not need a format, + * for example for the response to a DELETE request. * * @return \Drupal\rest\ResourceResponse * The altered response.