Skip to content

Commit 0c8c6a4

Browse files
committed
AC-465: Allow to configure input limit for RESTful endpoints
1 parent 85a3fc0 commit 0c8c6a4

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Magento\Framework\Api\SimpleDataObjectConverter;
1414
use Magento\Framework\App\ObjectManager;
1515
use Magento\Framework\Exception\InputException;
16-
use Magento\Framework\Exception\LocalizedException;
1716
use Magento\Framework\Exception\SerializationException;
1817
use Magento\Framework\ObjectManager\ConfigInterface;
1918
use Magento\Framework\ObjectManagerInterface;
@@ -98,7 +97,7 @@ class ServiceInputProcessor implements ServicePayloadConverterInterface
9897
private $defaultPageSize;
9998

10099
/**
101-
* @var DefaultPageSizeSetter
100+
* @var DefaultPageSizeSetter|null
102101
*/
103102
private $defaultPageSizeSetter;
104103

@@ -177,19 +176,19 @@ private function getNameFinder()
177176
* @param string $serviceMethodName name of the method that we are trying to call
178177
* @param array $inputArray data to send to method in key-value format
179178
* @return array list of parameters that can be used to call the service method
180-
* @throws Exception
181-
* @throws LocalizedException
179+
* @throws WebapiException
182180
*/
183181
public function process($serviceClassName, $serviceMethodName, array $inputArray)
184182
{
185183
$inputData = [];
186184
$inputError = [];
187-
188185
foreach ($this->methodsMap->getMethodParams($serviceClassName, $serviceMethodName) as $param) {
189186
$paramName = $param[MethodsMap::METHOD_META_NAME];
190187
$snakeCaseParamName = strtolower(preg_replace("/(?<=\\w)(?=[A-Z])/", "_$1", $paramName));
191188
if (isset($inputArray[$paramName]) || isset($inputArray[$snakeCaseParamName])) {
192-
$paramValue = $inputArray[$paramName] ?? $inputArray[$snakeCaseParamName];
189+
$paramValue = isset($inputArray[$paramName])
190+
? $inputArray[$paramName]
191+
: $inputArray[$snakeCaseParamName];
193192

194193
try {
195194
$inputData[] = $this->convertValue($paramValue, $param[MethodsMap::METHOD_META_TYPE]);
@@ -204,9 +203,7 @@ public function process($serviceClassName, $serviceMethodName, array $inputArray
204203
}
205204
}
206205
}
207-
208206
$this->processInputError($inputError);
209-
210207
return $inputData;
211208
}
212209

@@ -217,7 +214,7 @@ public function process($serviceClassName, $serviceMethodName, array $inputArray
217214
* @param array $data
218215
* @return array
219216
* @throws \ReflectionException
220-
* @throws LocalizedException
217+
* @throws \Magento\Framework\Exception\LocalizedException
221218
*/
222219
private function getConstructorData(string $className, array $data): array
223220
{
@@ -491,7 +488,7 @@ protected function _createDataObjectForTypeAndArrayValue($type, $customAttribute
491488
* @param mixed $data
492489
* @param string $type Convert given value to the this type
493490
* @return mixed
494-
* @throws LocalizedException
491+
* @throws \Magento\Framework\Exception\LocalizedException
495492
*/
496493
public function convertValue($data, $type)
497494
{

0 commit comments

Comments
 (0)