[BUGFIX] Use HTTP 400 instead of 500 when client is faulty 80/53580/3
authorXavier Perseguers <xavier@typo3.org>
Fri, 21 Jul 2017 11:53:38 +0000 (13:53 +0200)
committerAndreas Fernandez <typo3@scripting-base.de>
Mon, 24 Jul 2017 19:12:22 +0000 (21:12 +0200)
When checking for precondition in the request, HTTP 400 code should
be returned whenever the client is responsible for having issued a
bad request.

HTTP 500 indicates an internal error on the server, which is not the
case under such circumstance.

Change-Id: Ib7e63428b1a84b63e1a2a0c9d95513972be83d33
Resolves: #81941
Releases: master, 8.7
Reviewed-on: https://review.typo3.org/53580
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/backend/Classes/Controller/Page/LocalizationController.php

index 4270aab..c6e3395 100644 (file)
@@ -68,7 +68,7 @@ class LocalizationController
     {
         $params = $request->getQueryParams();
         if (!isset($params['pageId'], $params['colPos'], $params['languageId'])) {
-            $response = $response->withStatus(500);
+            $response = $response->withStatus(400);
             return $response;
         }
 
@@ -123,7 +123,7 @@ class LocalizationController
     {
         $params = $request->getQueryParams();
         if (!isset($params['pageId'], $params['colPos'], $params['destLanguageId'], $params['languageId'])) {
-            $response = $response->withStatus(500);
+            $response = $response->withStatus(400);
             return $response;
         }
 
@@ -159,7 +159,7 @@ class LocalizationController
         GeneralUtility::logDeprecatedFunction();
         $params = $request->getQueryParams();
         if (!isset($params['pageId'], $params['colPos'], $params['languageId'])) {
-            $response = $response->withStatus(500);
+            $response = $response->withStatus(400);
             return $response;
         }
 
@@ -186,13 +186,13 @@ class LocalizationController
     {
         $params = $request->getQueryParams();
         if (!isset($params['pageId'], $params['srcLanguageId'], $params['destLanguageId'], $params['action'], $params['uidList'])) {
-            $response = $response->withStatus(500);
+            $response = $response->withStatus(400);
             return $response;
         }
 
         if ($params['action'] !== static::ACTION_COPY && $params['action'] !== static::ACTION_LOCALIZE) {
             $response->getBody()->write('Invalid action "' . $params['action'] . '" called.');
-            $response = $response->withStatus(500);
+            $response = $response->withStatus(400);
             return $response;
         }