Skip to content

Commit 2f5c399

Browse files
authored
Merge pull request #528 from magento-performance/ACPT-1191
ACPT-1191: Fix Quote related issues on Application Server
2 parents 8f1e027 + 067ae65 commit 2f5c399

File tree

15 files changed

+74
-16
lines changed

15 files changed

+74
-16
lines changed

app/code/Magento/Config/Model/ResourceModel/Config.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Config\Model\ResourceModel;
77

88
use Magento\Framework\App\Config\ScopeConfigInterface;
9+
use Magento\Framework\MessageQueue\PoisonPill\PoisonPillPutInterface;
910

1011
/**
1112
* Core Resource Resource Model
@@ -17,14 +18,23 @@
1718
class Config extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb implements
1819
\Magento\Framework\App\Config\ConfigResource\ConfigInterface
1920
{
21+
/**
22+
* @var PoisonPillPutInterface
23+
*/
24+
private $pillPut;
25+
2026
/**
2127
* Define main table
2228
*
29+
* @param PoisonPillPutInterface|null $pillPut
2330
* @return void
2431
*/
25-
protected function _construct()
26-
{
32+
protected function _construct(
33+
PoisonPillPutInterface $pillPut = null
34+
) {
2735
$this->_init('core_config_data', 'config_id');
36+
$this->pillPut = $pillPut ?: \Magento\Framework\App\ObjectManager::getInstance()
37+
->get(PoisonPillPutInterface::class);
2838
}
2939

3040
/**
@@ -61,6 +71,7 @@ public function saveConfig($path, $value, $scope = ScopeConfigInterface::SCOPE_T
6171
} else {
6272
$connection->insert($this->getMainTable(), $newData);
6373
}
74+
$this->pillPut->put();
6475
return $this;
6576
}
6677

@@ -83,6 +94,7 @@ public function deleteConfig($path, $scope = ScopeConfigInterface::SCOPE_TYPE_DE
8394
$connection->quoteInto('scope_id = ?', $scopeId)
8495
]
8596
);
97+
$this->pillPut->put();
8698
return $this;
8799
}
88100
}

app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Magento\Framework\DB\Select;
1818
use Magento\Framework\Exception\CouldNotDeleteException;
1919
use Magento\Framework\Exception\LocalizedException;
20+
use Magento\Framework\MessageQueue\PoisonPill\PoisonPillPutInterface;
2021
use Magento\Framework\Model\AbstractModel;
2122
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
2223
use Magento\Framework\Model\ResourceModel\Db\Context;
@@ -53,23 +54,32 @@ class Attribute extends AbstractDb
5354
*/
5455
private $config;
5556

57+
/**
58+
* @var PoisonPillPutInterface
59+
*/
60+
private $pillPut;
61+
5662
/**
5763
* Class constructor
5864
*
5965
* @param Context $context
6066
* @param StoreManagerInterface $storeManager
6167
* @param Type $eavEntityType
6268
* @param string $connectionName
69+
* @param PoisonPillPutInterface|null $pillPut
6370
* @codeCoverageIgnore
6471
*/
6572
public function __construct(
6673
Context $context,
6774
StoreManagerInterface $storeManager,
6875
Type $eavEntityType,
69-
$connectionName = null
76+
$connectionName = null,
77+
PoisonPillPutInterface $pillPut = null
7078
) {
7179
$this->_storeManager = $storeManager;
7280
$this->_eavEntityType = $eavEntityType;
81+
$this->pillPut = $pillPut ?: \Magento\Framework\App\ObjectManager::getInstance()
82+
->get(PoisonPillPutInterface::class);
7383
parent::__construct($context, $connectionName);
7484
}
7585

@@ -235,6 +245,7 @@ protected function _afterSave(AbstractModel $object)
235245
$object
236246
);
237247
$this->getConfig()->clear();
248+
$this->pillPut->put();
238249
return parent::_afterSave($object);
239250
}
240251

@@ -249,6 +260,7 @@ protected function _afterSave(AbstractModel $object)
249260
protected function _afterDelete(AbstractModel $object)
250261
{
251262
$this->getConfig()->clear();
263+
$this->pillPut->put();
252264
return $this;
253265
}
254266

@@ -390,7 +402,7 @@ protected function _saveOption(AbstractModel $object)
390402
if ($object->getDefaultValue()) {
391403
$defaultValue[] = $object->getDefaultValue();
392404
}
393-
405+
394406
$this->_saveDefaultValue($object, $defaultValue);
395407
return $this;
396408
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public function __construct(QuoteTotalsCollector $quoteTotalsCollector)
5151
*/
5252
public function _resetState(): void
5353
{
54-
$this->quoteTotals = [];
55-
$this->addressTotals = [];
54+
$this->clearTotals();
5655
}
5756

5857
/**

app/code/Magento/Store/Model/StoreManager.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
*/
1919
class StoreManager implements
2020
\Magento\Store\Model\StoreManagerInterface,
21-
\Magento\Store\Api\StoreWebsiteRelationInterface
21+
\Magento\Store\Api\StoreWebsiteRelationInterface,
22+
ResetAfterRequestInterface
2223
{
2324
/**
2425
* Application run code
@@ -329,4 +330,12 @@ public function __debugInfo()
329330
{
330331
return ['currentStoreId' => $this->currentStoreId];
331332
}
333+
334+
/**
335+
* @inheritDoc
336+
*/
337+
public function _resetState(): void
338+
{
339+
$this->reinitStores();
340+
}
332341
}

app/code/Magento/Tax/Model/Calculation.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
/**
2424
* Tax Calculation Model
25+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
2526
* @SuppressWarnings(PHPMD.TooManyFields)
2627
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2728
*/
@@ -526,11 +527,13 @@ public function getRateRequest(
526527
//fallback to default address for registered customer
527528
try {
528529
$defaultBilling = $this->customerAccountManagement->getDefaultBillingAddress($customerId);
530+
// phpcs:disable Magento2.CodeAnalysis.EmptyBlock.DetectedCatch
529531
} catch (NoSuchEntityException $e) {
530532
}
531533

532534
try {
533535
$defaultShipping = $this->customerAccountManagement->getDefaultShippingAddress($customerId);
536+
// phpcs:disable Magento2.CodeAnalysis.EmptyBlock.DetectedCatch
534537
} catch (NoSuchEntityException $e) {
535538
}
536539

app/code/Magento/Tax/Model/ResourceModel/Calculation.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
*/
1010
namespace Magento\Tax\Model\ResourceModel;
1111

12-
class Calculation extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
12+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
13+
14+
class Calculation extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb implements ResetAfterRequestInterface
1315
{
1416
/**
1517
* Store ISO 3166-1 alpha-2 USA country code
@@ -473,4 +475,12 @@ public function getRateIds($request)
473475

474476
return $result;
475477
}
478+
479+
/**
480+
* @inheritDoc
481+
*/
482+
public function _resetState(): void
483+
{
484+
$this->_ratesCache = [];
485+
}
476486
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/CartPromotionsTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ public function testCartPromotionsMultipleCartRules()
198198
* Tax rate = 7.5%
199199
* Cart rule to apply 50% for products assigned to a specific category
200200
*
201+
* @magentoConfigFixture default_store tax/calculation/discount_tax 1
201202
* @magentoApiDataFixture Magento/Catalog/_files/multiple_products.php
202203
* @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_rule_for_region_1.php
203204
* @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_calculation_price_and_cart_display_settings.php

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetSelectedShippingMethodTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ protected function setUp(): void
3939
}
4040

4141
/**
42+
* @magentoConfigFixture default_store tax/calculation/price_includes_tax 1
4243
* @magentoConfigFixture default_store tax/calculation/shipping_includes_tax 1
4344
* @magentoConfigFixture default_store tax/cart_display/shipping 2
4445
* @magentoConfigFixture default_store tax/classes/shipping_tax_class 2

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPurchaseOrderPaymentMethodOnCartTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public function testSetPurchaseOrderPaymentMethodOnCartWithoutPurchaseOrderNumbe
133133
}
134134

135135
/**
136+
* @magentoConfigFixture default_store payment/purchaseorder/active 0
136137
* @magentoApiDataFixture Magento/Customer/_files/customer.php
137138
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
138139
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingMethodsOnCartTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public function testReSetShippingMethod()
138138
}
139139

140140
/**
141+
* @magentoConfigFixture default_store carriers/freeshipping/active 0
141142
* @magentoApiDataFixture Magento/Customer/_files/customer.php
142143
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
143144
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
@@ -385,7 +386,9 @@ private function getQuery(
385386
public function testSetShippingMethodOnAnEmptyCart()
386387
{
387388
$this->expectException(\Exception::class);
388-
$this->expectExceptionMessage('The shipping method can\'t be set for an empty cart. Add an item to cart and try again.');
389+
$this->expectExceptionMessage(
390+
'The shipping method can\'t be set for an empty cart. Add an item to cart and try again.'
391+
);
389392

390393
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
391394
$carrierCode = 'flatrate';

0 commit comments

Comments
 (0)