Skip to content

Commit 2e9969f

Browse files
committed
ACP2E-3774: Concurrent Calls to Reorder GraphQL API - Same Products Added to Different Rows
1 parent 9a479ae commit 2e9969f

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

app/code/Magento/SalesGraphQl/Model/Resolver/Reorder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function resolve(
8787
);
8888
}
8989

90-
$lockName = implode('_', [$currentUserId, $storeId, $orderNumber]);
90+
$lockName = hash('sha256', $orderNumber);
9191
if ($this->lockManager->lock(self::LOCK_PREFIX . $lockName, self::LOCK_TIMEOUT)) {
9292
try {
9393
$reorderOutput = $this->reorder->execute($orderNumber, $storeId);
@@ -96,7 +96,7 @@ public function resolve(
9696
}
9797
} else {
9898
throw new \Magento\Framework\Exception\LocalizedException(
99-
__('The reorder is locked for processing. The concurrent request has been aborted.')
99+
__('Sorry, there has been an error processing your request. Please try again later.')
100100
);
101101
}
102102

app/code/Magento/SalesGraphQl/Test/Unit/Model/Resolver/ReorderTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99

1010
use Magento\Framework\Lock\LockManagerInterface;
1111
use Magento\GraphQl\Model\Query\Context;
12-
use Magento\GraphQl\Model\Query\ContextExtension;
12+
use Magento\GraphQl\Model\Query\ContextExtensionInterface;
13+
use Magento\Sales\Model\Order;
1314
use Magento\Sales\Model\OrderFactory;
1415
use Magento\Sales\Model\Reorder\Reorder;
16+
use Magento\Store\Api\Data\StoreInterface;
1517
use PHPUnit\Framework\MockObject\MockObject;
1618
use PHPUnit\Framework\TestCase;
1719
use Magento\SalesGraphQl\Model\Resolver\Reorder as Subject;
@@ -26,7 +28,7 @@ class ReorderTest extends TestCase
2628
private $subject;
2729

2830
/**
29-
* @var ContextExtension|MockObject
31+
* @var ContextExtensionInterface|MockObject
3032
*/
3133
private $extensionAttributesMock;
3234

@@ -73,12 +75,14 @@ public function testResolve(): void
7375
$args = ['orderNumber' => '00000010'];
7476
$value = [];
7577

76-
$this->extensionAttributesMock = $this->createMock(ContextExtension::class);
78+
$this->extensionAttributesMock = $this->getMockBuilder(ContextExtensionInterface::class)
79+
->disableOriginalConstructor()
80+
->getMockForAbstractClass();
7781
$this->extensionAttributesMock->expects($this->once())
7882
->method('getIsCustomer')
7983
->willReturn(true);
8084

81-
$store = $this->createMock(\Magento\Store\Api\Data\StoreInterface::class);
85+
$store = $this->createMock(StoreInterface::class);
8286
$store->expects($this->once())
8387
->method('getId')
8488
->willReturn(1);
@@ -94,7 +98,7 @@ public function testResolve(): void
9498
->method('getUserId')
9599
->willReturn($contextCustomerId);
96100

97-
$order = $this->createMock(\Magento\Sales\Model\Order::class);
101+
$order = $this->createMock(Order::class);
98102
$order->expects($this->once())
99103
->method('loadByIncrementIdAndStoreId')
100104
->willReturnSelf();

app/code/Magento/SalesGraphQl/i18n/en_US.csv

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)