From f7deedb6959dfe396ac3b27d2e377839863001ec Mon Sep 17 00:00:00 2001
From: apersky <65309-apersky@users.noreply.drupalcode.org>
Date: Thu, 2 Nov 2023 20:17:47 +0000
Subject: [PATCH 1/2] Add workaround for if there is no formats for a DELETE
 call

---
 .../src/EventSubscriber/ResourceResponseSubscriber.php     | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php b/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php
index 9b5d24836dbb..5cc7dc970a7d 100644
--- a/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php
+++ b/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php
@@ -102,6 +102,13 @@ public function getResponseFormat(RouteMatchInterface $route_match, Request $req
     $requested_format = $request->getRequestFormat();
     $content_type_format = $request->getContentType();
 
+    // Workaround for if there is no formats for a DELETE call:
+    // make the response formats match the format of the request
+    if ($request->getMethod() === 'DELETE') {
+      if (empty($acceptable_request_formats)) $acceptable_request_formats = [$requested_format];
+      if (empty($acceptable_formats)) $acceptable_formats = [$requested_format];
+    }
+
     // If an acceptable response format is requested, then use that. Otherwise,
     // including and particularly when the client forgot to specify a response
     // format, then use heuristics to select the format that is most likely
-- 
GitLab


From 28fba577ef9fb4474fbeef31a6e6202171a6f728 Mon Sep 17 00:00:00 2001
From: Gaurav Mahlawat <gaurav.mahlawat@axelerant.com>
Date: Fri, 3 Nov 2023 09:01:59 +0530
Subject: [PATCH 2/2] Updated Inline control structures with drupal standards

---
 .../src/EventSubscriber/ResourceResponseSubscriber.php    | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php b/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php
index 5cc7dc970a7d..d1360b42498b 100644
--- a/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php
+++ b/core/modules/rest/src/EventSubscriber/ResourceResponseSubscriber.php
@@ -105,8 +105,12 @@ public function getResponseFormat(RouteMatchInterface $route_match, Request $req
     // Workaround for if there is no formats for a DELETE call:
     // make the response formats match the format of the request
     if ($request->getMethod() === 'DELETE') {
-      if (empty($acceptable_request_formats)) $acceptable_request_formats = [$requested_format];
-      if (empty($acceptable_formats)) $acceptable_formats = [$requested_format];
+      if (empty($acceptable_request_formats)) {
+        $acceptable_request_formats = [$requested_format];
+      }
+      if (empty($acceptable_formats)) {
+        $acceptable_formats = [$requested_format];
+      }
     }
 
     // If an acceptable response format is requested, then use that. Otherwise,
-- 
GitLab

