Skip to content

Commit 95c2ae9

Browse files
Alter Tests to add new exception catches (plus a few main catches)
If a callback in commit throws an excecption, the calling plugin needs to be able to distinguish this from a unsuccessful commit, so that it doesn't attempt a rollback on an already commited transaction. (Which would cause an “Asymmetric transaction rollback" error)
1 parent 7e30967 commit 95c2ae9

File tree

11 files changed

+20
-2
lines changed

11 files changed

+20
-2
lines changed

app/code/Magento/Authorization/Model/ResourceModel/Rules.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ public function saveRel(\Magento\Authorization\Model\Rules $rule)
121121

122122
$connection->commit();
123123
$this->aclDataCache->clean();
124-
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
125-
throw $e->getPrevious();
126124
} catch (\Magento\Framework\Exception\LocalizedException $e) {
127125
$connection->rollBack();
128126
throw $e;

app/code/Magento/Sales/Model/Order/Status.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public function assignState($state, $isDefault = false, $visibleOnFront = false)
7777
try {
7878
$resource->assignState($this->getStatus(), $state, $isDefault, $visibleOnFront);
7979
$resource->commit();
80+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
81+
throw $e->getPrevious();
8082
} catch (\Exception $e) {
8183
$resource->rollBack();
8284
throw $e;

app/code/Magento/Store/Model/Config/Importer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ public function import(array $data)
105105
foreach ($actions as $action) {
106106
$this->processFactory->create($action)->run($data);
107107
}
108+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
109+
throw $e->getPrevious();
108110
} catch (\Exception $exception) {
109111
$this->resource->rollBack();
110112
$this->reinitStores();

dev/tests/integration/testsuite/Magento/Reports/_files/viewed_products.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
try {
5555
$reportResource->aggregate();
5656
$reportResource->commit();
57+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
58+
throw $e->getPrevious();
5759
} catch (\Exception $e) {
5860
$reportResource->rollBack();
5961
throw $e;

dev/tests/integration/testsuite/Magento/Sales/_files/report_bestsellers.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
try {
1515
$reportResource->aggregate();
1616
$reportResource->commit();
17+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
18+
throw $e->getPrevious();
1719
} catch (\Exception $e) {
1820
$reportResource->rollBack();
1921
throw $e;

dev/tests/integration/testsuite/Magento/Sales/_files/report_invoiced.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
try {
1515
$reportResource->aggregate();
1616
$reportResource->commit();
17+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
18+
throw $e->getPrevious();
1719
} catch (\Exception $e) {
1820
$reportResource->rollBack();
1921
throw $e;

dev/tests/integration/testsuite/Magento/Sales/_files/report_refunded.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
try {
1515
$reportResource->aggregate();
1616
$reportResource->commit();
17+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
18+
throw $e->getPrevious();
1719
} catch (\Exception $e) {
1820
$reportResource->rollBack();
1921
throw $e;

dev/tests/integration/testsuite/Magento/Sales/_files/report_shipping.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
try {
1515
$reportResource->aggregate();
1616
$reportResource->commit();
17+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
18+
throw $e->getPrevious();
1719
} catch (\Exception $e) {
1820
$reportResource->rollBack();
1921
throw $e;

dev/tests/integration/testsuite/Magento/SalesRule/_files/report_coupons.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
try {
1515
$reportResource->aggregate();
1616
$reportResource->commit();
17+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
18+
throw $e->getPrevious();
1719
} catch (\Exception $e) {
1820
$reportResource->rollBack();
1921
throw $e;

dev/tests/integration/testsuite/Magento/Tax/_files/report_tax.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
try {
1414
$reportResource->aggregate();
1515
$reportResource->commit();
16+
} catch (\Magento\Framework\Exception\AfterCommitException $e) {
17+
throw $e->getPrevious();
1618
} catch (\Exception $e) {
1719
$reportResource->rollBack();
1820
throw $e;

0 commit comments

Comments
 (0)