[BUGFIX] Use HTTP 400 instead of 500 when client is faulty 64/53564/2
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 18:48:39 +0000 (20:48 +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/53564
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Helmut Hummel <typo3@helhum.io>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
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 21ed99c..a049cc0 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;
         }
 
@@ -157,13 +157,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;
         }