Skip to content

Commit f3a8391

Browse files
ENGCOM-8825: Restore UNIQUE_CHECKS mysql variable to its original value when done … #32286
2 parents ff42eed + 0931e3a commit f3a8391

File tree

8 files changed

+41
-12
lines changed

8 files changed

+41
-12
lines changed

app/code/Magento/AwsS3/Test/Mftf/Test/AwsS3StorefrontPrintOrderGuestTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
<description value="Print Order from Guest on Frontend"/>
1616
<severity value="BLOCKER"/>
1717
<testCaseId value="MC-38689"/>
18+
<skip>
19+
<issueId value="MQE-2834" />
20+
</skip>
1821
<group value="remote_storage_aws_s3"/>
1922
</annotations>
2023
<before>

app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest/CheckCheckoutSuccessPageAsRegisterCustomerTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
<description value="To be sure that other elements of Success page are shown for placed order as registered Customer."/>
1616
<severity value="CRITICAL"/>
1717
<testCaseId value="MC-16488"/>
18+
<skip>
19+
<issueId value="MQE-2834" />
20+
</skip>
1821
<group value="checkout"/>
1922
</annotations>
2023

app/code/Magento/QuoteGraphQl/Model/Cart/AddProductsToCart.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
namespace Magento\QuoteGraphQl\Model\Cart;
99

1010
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
11-
use Magento\Framework\Message\MessageInterface;
1211
use Magento\Quote\Api\CartRepositoryInterface;
1312
use Magento\Quote\Model\Quote;
1413

@@ -53,7 +52,6 @@ public function execute(Quote $cart, array $cartItems): void
5352
foreach ($cartItems as $cartItemData) {
5453
$this->addProductToCart->execute($cart, $cartItemData);
5554
}
56-
5755
$this->cartRepository->save($cart);
5856
}
5957
}

app/code/Magento/QuoteGraphQl/Model/Resolver/AddSimpleProductsToCart.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1414
use Magento\QuoteGraphQl\Model\Cart\AddProductsToCart;
1515
use Magento\QuoteGraphQl\Model\Cart\GetCartForUser;
16+
use Magento\Framework\Lock\LockManagerInterface;
1617

1718
/**
1819
* Add simple products to cart GraphQl resolver
@@ -30,16 +31,24 @@ class AddSimpleProductsToCart implements ResolverInterface
3031
*/
3132
private $addProductsToCart;
3233

34+
/**
35+
* @var LockManagerInterface
36+
*/
37+
private $lockManager;
38+
3339
/**
3440
* @param GetCartForUser $getCartForUser
3541
* @param AddProductsToCart $addProductsToCart
42+
* @param LockManagerInterface $lockManager
3643
*/
3744
public function __construct(
3845
GetCartForUser $getCartForUser,
39-
AddProductsToCart $addProductsToCart
46+
AddProductsToCart $addProductsToCart,
47+
LockManagerInterface $lockManager
4048
) {
4149
$this->getCartForUser = $getCartForUser;
4250
$this->addProductsToCart = $addProductsToCart;
51+
$this->lockManager = $lockManager;
4352
}
4453

4554
/**
@@ -58,12 +67,20 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
5867
throw new GraphQlInputException(__('Required parameter "cart_items" is missing'));
5968
}
6069
$cartItems = $args['input']['cart_items'];
61-
6270
$storeId = (int)$context->getExtensionAttributes()->getStore()->getId();
71+
72+
$lockName = 'cart_processing_lock_' . $maskedCartId;
73+
while ($this->lockManager->isLocked($lockName)) {
74+
// wait till other process working with the same cart complete
75+
usleep(rand(100, 600));
76+
}
77+
$this->lockManager->lock($lockName, 1);
78+
6379
$cart = $this->getCartForUser->execute($maskedCartId, $context->getUserId(), $storeId);
6480
$this->addProductsToCart->execute($cart, $cartItems);
65-
6681
$cart = $this->getCartForUser->execute($maskedCartId, $context->getUserId(), $storeId);
82+
83+
$this->lockManager->unlock($lockName);
6784
return [
6885
'cart' => [
6986
'model' => $cart,

app/code/Magento/Sales/Test/Mftf/Test/StorefrontPrintOrderGuestTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<description value="Print Order from Guest on Frontend"/>
1717
<severity value="CRITICAL"/>
1818
<testCaseId value="MC-28494"/>
19+
<skip>
20+
<issueId value="MQE-2834" />
21+
</skip>
1922
<group value="sales"/>
2023
<group value="mtf_migrated"/>
2124
</annotations>

app/code/Magento/Sales/Test/Mftf/Test/StorefrontRedirectToOrderHistoryTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<description value="Check while order printing URL with an id of not relevant order redirects to order history"/>
1717
<severity value="MAJOR"/>
1818
<testCaseId value="MC-28543"/>
19+
<skip>
20+
<issueId value="MQE-2834" />
21+
</skip>
1922
<group value="sales"/>
2023
</annotations>
2124
<before>

lib/internal/Magento/Framework/Setup/Declaration/Schema/OperationsExecutor.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ public function getDestructiveOperations()
132132
private function startSetupForAllConnections()
133133
{
134134
foreach ($this->sharding->getResources() as $resource) {
135-
$this->resourceConnection->getConnection($resource)
136-
->startSetup();
137-
$this->resourceConnection->getConnection($resource)
138-
->query('SET UNIQUE_CHECKS=0');
135+
$connection = $this->resourceConnection->getConnection($resource);
136+
137+
$connection->startSetup();
138+
$connection->query('SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0');
139139
}
140140
}
141141

@@ -148,8 +148,10 @@ private function startSetupForAllConnections()
148148
private function endSetupForAllConnections()
149149
{
150150
foreach ($this->sharding->getResources() as $resource) {
151-
$this->resourceConnection->getConnection($resource)
152-
->endSetup();
151+
$connection = $this->resourceConnection->getConnection($resource);
152+
153+
$connection->query('SET UNIQUE_CHECKS=IF(@OLD_UNIQUE_CHECKS=0, 0, 1)');
154+
$connection->endSetup();
153155
}
154156
}
155157

lib/internal/Magento/Framework/Setup/Test/Unit/Declaration/Schema/OperationsExecutorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function testExecute()
160160
$connectionMock = $this->getMockBuilder(Mysql::class)
161161
->disableOriginalConstructor()
162162
->getMock();
163-
$this->resourceConnectionMock->expects(self::exactly(3))
163+
$this->resourceConnectionMock->expects(self::exactly(2))
164164
->method('getConnection')
165165
->with('default')
166166
->willReturn($connectionMock);

0 commit comments

Comments
 (0)