Skip to content

Commit 74f5a2f

Browse files
Merge remote-tracking branch '38282/fix-35931' into commpr-21755-0809
2 parents 45fc4cd + 04a191b commit 74f5a2f

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

app/code/Magento/Webapi/Controller/Rest/SynchronousRequestProcessor.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2018 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

88
namespace Magento\Webapi\Controller\Rest;
99

10+
use Magento\Framework\Webapi\Exception as WebapiException;
1011
use Magento\Framework\Webapi\Rest\Response as RestResponse;
1112
use Magento\Framework\Webapi\ServiceOutputProcessor;
1213
use Magento\Framework\Webapi\Rest\Response\FieldsFilter;
@@ -19,7 +20,7 @@
1920
*/
2021
class SynchronousRequestProcessor implements RequestProcessorInterface
2122
{
22-
const PROCESSOR_PATH = "/^\\/V\\d+/";
23+
public const PROCESSOR_PATH = "/^\\/V\\d+/";
2324

2425
/**
2526
* @var RestResponse
@@ -78,7 +79,7 @@ public function __construct(
7879
}
7980

8081
/**
81-
* {@inheritdoc}
82+
* @inheritdoc
8283
*/
8384
public function process(\Magento\Framework\Webapi\Rest\Request $request)
8485
{
@@ -92,7 +93,13 @@ public function process(\Magento\Framework\Webapi\Rest\Request $request)
9293
/**
9394
* @var \Magento\Framework\Api\AbstractExtensibleObject $outputData
9495
*/
95-
$outputData = call_user_func_array([$service, $serviceMethodName], $inputParams);
96+
try {
97+
// phpcs:disable Magento2.Functions.DiscouragedFunction
98+
$outputData = call_user_func_array([$service, $serviceMethodName], $inputParams);
99+
// phpcs:enable Magento2.Functions.DiscouragedFunction
100+
} catch (\TypeError $e) {
101+
throw new WebapiException(__($e->getMessage()));
102+
}
96103
$outputData = $this->serviceOutputProcessor->process(
97104
$outputData,
98105
$serviceClassName,
@@ -109,7 +116,7 @@ public function process(\Magento\Framework\Webapi\Rest\Request $request)
109116
}
110117

111118
/**
112-
* {@inheritdoc}
119+
* @inheritdoc
113120
*/
114121
public function canProcess(\Magento\Framework\Webapi\Rest\Request $request)
115122
{

dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipOrderTest.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2016 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -181,6 +181,26 @@ public function testShipOrder()
181181
);
182182
}
183183

184+
/**
185+
* @magentoApiDataFixture Magento/Sales/_files/order_new.php
186+
*/
187+
public function testShipOrderWithTypeError()
188+
{
189+
/** @var Order $existingOrder */
190+
$existingOrder = $this->getOrder('100000001');
191+
192+
$requestData = [
193+
'orderId' => $existingOrder->getId(),
194+
'items' => "[]",
195+
];
196+
197+
try {
198+
$this->_webApiCall($this->getServiceInfo($existingOrder), $requestData);
199+
$this->fail('Expected exception was not raised');
200+
} catch (\Exception $exception) {
201+
}
202+
}
203+
184204
/**
185205
* Tests that not providing a tracking number produces the correct error. See MAGETWO-95429
186206
* @codingStandardsIgnoreStart

0 commit comments

Comments
 (0)