Skip to content

Commit f4e7553

Browse files
author
hwyu@adobe.com
committed
MC-36035: Prevent input based resource allocation
- Fixed web-api
1 parent a86a8ee commit f4e7553

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

app/etc/di.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,4 +1959,9 @@
19591959
<argument name="maxPageSize" xsi:type="number">300</argument>
19601960
</arguments>
19611961
</type>
1962+
<type name="Magento\Framework\Webapi\ServiceInputProcessor">
1963+
<arguments>
1964+
<argument name="defaultPageSize" xsi:type="number">20</argument>
1965+
</arguments>
1966+
</type>
19621967
</config>

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ class ServiceInputProcessor implements ServicePayloadConverterInterface
9292
*/
9393
private $serviceInputValidator;
9494

95+
/**
96+
* @var int
97+
*/
98+
private $defaultPageSize;
99+
95100
/**
96101
* Initialize dependencies.
97102
*
@@ -104,6 +109,7 @@ class ServiceInputProcessor implements ServicePayloadConverterInterface
104109
* @param ConfigInterface|null $config
105110
* @param array $customAttributePreprocessors
106111
* @param ServiceInputValidatorInterface|null $serviceInputValidator
112+
* @param int|null $defaultPageSize
107113
*/
108114
public function __construct(
109115
TypeProcessor $typeProcessor,
@@ -114,7 +120,8 @@ public function __construct(
114120
ServiceTypeToEntityTypeMap $serviceTypeToEntityTypeMap = null,
115121
ConfigInterface $config = null,
116122
array $customAttributePreprocessors = [],
117-
ServiceInputValidatorInterface $serviceInputValidator = null
123+
ServiceInputValidatorInterface $serviceInputValidator = null,
124+
int $defaultPageSize = null
118125
) {
119126
$this->typeProcessor = $typeProcessor;
120127
$this->objectManager = $objectManager;
@@ -128,6 +135,7 @@ public function __construct(
128135
$this->customAttributePreprocessors = $customAttributePreprocessors;
129136
$this->serviceInputValidator = $serviceInputValidator
130137
?: ObjectManager::getInstance()->get(ServiceInputValidatorInterface::class);
138+
$this->defaultPageSize = $defaultPageSize ?: 20;
131139
}
132140

133141
/**
@@ -304,7 +312,7 @@ protected function _createFromArray($className, $data)
304312
if ($object instanceof SearchCriteriaInterface
305313
&& $object->getPageSize() === null
306314
) {
307-
$object->setPageSize(20);
315+
$object->setPageSize($this->defaultPageSize);
308316
}
309317

310318
return $object;

0 commit comments

Comments
 (0)