From 141fa5efe8008cba70bf76c0ea472624b4546bc7 Mon Sep 17 00:00:00 2001 From: waynemowdirect Date: Fri, 2 Jun 2017 16:12:02 +0100 Subject: [PATCH 01/16] testing travis --- forceBuild.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 forceBuild.txt diff --git a/forceBuild.txt b/forceBuild.txt new file mode 100644 index 0000000000000..6dacae433f39f --- /dev/null +++ b/forceBuild.txt @@ -0,0 +1 @@ +forcing From f0b320b75757eb9f78c56cee057e0bfa990ebe0d Mon Sep 17 00:00:00 2001 From: waynemowdirect Date: Wed, 14 Jun 2017 12:36:49 +0100 Subject: [PATCH 02/16] Add AfterCommitException MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../Framework/Exception/AfterCommitException.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lib/internal/Magento/Framework/Exception/AfterCommitException.php diff --git a/lib/internal/Magento/Framework/Exception/AfterCommitException.php b/lib/internal/Magento/Framework/Exception/AfterCommitException.php new file mode 100644 index 0000000000000..4baa5aaf0d6fe --- /dev/null +++ b/lib/internal/Magento/Framework/Exception/AfterCommitException.php @@ -0,0 +1,15 @@ + Date: Wed, 14 Jun 2017 13:49:56 +0100 Subject: [PATCH 03/16] Throw new AfterCommitException from AbstractResource.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../Magento/Framework/Model/ResourceModel/AbstractResource.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php b/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php index 1e3de56f495bf..90cc88bfc0817 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php @@ -9,6 +9,7 @@ use Magento\Framework\DataObject; use Magento\Framework\Model\CallbackPool; use Magento\Framework\Serialize\Serializer\Json; +use Magento\Framework\Exception\AfterCommitException; /** * Abstract resource model @@ -91,7 +92,7 @@ public function commit() call_user_func($callback); } } catch (\Exception $e) { - throw $e; + throw new AfterCommitException(null, null, $e); } } return $this; From 1cc3787e4c446dfa65af9d06d754208da1b816b7 Mon Sep 17 00:00:00 2001 From: waynemowdirect Date: Wed, 14 Jun 2017 16:12:32 +0100 Subject: [PATCH 04/16] Catch AfterCommitException from AbstractResource.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../Magento/Authorization/Model/ResourceModel/Rules.php | 2 ++ .../Catalog/Console/Command/ProductAttributesCleanUp.php | 2 ++ app/code/Magento/Catalog/Model/Category.php | 2 ++ .../Model/Plugin/ProductRepository/TransactionWrapper.php | 6 ++++++ .../Model/ResourceModel/Product/Indexer/Eav/AbstractEav.php | 2 ++ .../ResourceModel/Product/Indexer/Price/DefaultPrice.php | 2 ++ .../Model/ResourceModel/Indexer/Stock/DefaultStock.php | 2 ++ .../Model/Indexer/Fulltext/Plugin/Category.php | 2 ++ .../CatalogSearch/Model/Indexer/Fulltext/Plugin/Product.php | 2 ++ .../Model/Plugin/CustomerRepository/TransactionWrapper.php | 2 ++ app/code/Magento/Eav/Model/Entity/AbstractEntity.php | 2 ++ app/code/Magento/Eav/Model/Entity/Type.php | 2 ++ .../Eav/Model/Entity/VersionControl/AbstractEntity.php | 2 ++ .../EncryptionKey/Model/ResourceModel/Key/Change.php | 2 ++ .../Indexer/Model/ResourceModel/AbstractResource.php | 2 ++ app/code/Magento/Sitemap/Model/ResourceModel/Cms/Page.php | 2 ++ 16 files changed, 36 insertions(+) diff --git a/app/code/Magento/Authorization/Model/ResourceModel/Rules.php b/app/code/Magento/Authorization/Model/ResourceModel/Rules.php index e888b81e002df..1ed44f405ccb9 100644 --- a/app/code/Magento/Authorization/Model/ResourceModel/Rules.php +++ b/app/code/Magento/Authorization/Model/ResourceModel/Rules.php @@ -121,6 +121,8 @@ public function saveRel(\Magento\Authorization\Model\Rules $rule) $connection->commit(); $this->aclDataCache->clean(); + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Magento\Framework\Exception\LocalizedException $e) { $connection->rollBack(); throw $e; diff --git a/app/code/Magento/Catalog/Console/Command/ProductAttributesCleanUp.php b/app/code/Magento/Catalog/Console/Command/ProductAttributesCleanUp.php index 4fc63d1d662c0..0291f0ba6921a 100644 --- a/app/code/Magento/Catalog/Console/Command/ProductAttributesCleanUp.php +++ b/app/code/Magento/Catalog/Console/Command/ProductAttributesCleanUp.php @@ -102,6 +102,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln("Unused product attributes successfully cleaned up:"); $output->writeln(" " . implode("\n ", $attributeTables) . ""); return \Magento\Framework\Console\Cli::RETURN_SUCCESS; + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $exception) { $this->attributeResource->rollBack(); diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php index 311bd4f9422fd..833e26be706cc 100644 --- a/app/code/Magento/Catalog/Model/Category.php +++ b/app/code/Magento/Catalog/Model/Category.php @@ -429,6 +429,8 @@ public function move($parentId, $afterCategoryId) // Set data for indexer $this->setAffectedCategoryIds([$this->getId(), $oldParentId, $parentId]); + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $this->_getResource()->rollBack(); throw $e; diff --git a/app/code/Magento/Catalog/Model/Plugin/ProductRepository/TransactionWrapper.php b/app/code/Magento/Catalog/Model/Plugin/ProductRepository/TransactionWrapper.php index c88215d92357e..c437e2220844a 100644 --- a/app/code/Magento/Catalog/Model/Plugin/ProductRepository/TransactionWrapper.php +++ b/app/code/Magento/Catalog/Model/Plugin/ProductRepository/TransactionWrapper.php @@ -44,6 +44,8 @@ public function aroundSave( $result = $proceed($product, $saveOptions); $this->resourceModel->commit(); return $result; + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $this->resourceModel->rollBack(); throw $e; @@ -69,6 +71,8 @@ public function aroundDelete( $result = $proceed($product); $this->resourceModel->commit(); return $result; + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $this->resourceModel->rollBack(); throw $e; @@ -94,6 +98,8 @@ public function aroundDeleteById( $result = $proceed($productSku); $this->resourceModel->commit(); return $result; + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $this->resourceModel->rollBack(); throw $e; diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/AbstractEav.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/AbstractEav.php index 8f4a47804c8ae..3bdf244077b8a 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/AbstractEav.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/AbstractEav.php @@ -77,6 +77,8 @@ public function reindexAll() $this->_removeNotVisibleEntityFromIndex(); $this->syncData(); $this->commit(); + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $this->rollBack(); throw $e; diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index a613690209432..dca51a181ef89 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -167,6 +167,8 @@ public function reindexAll() try { $this->reindex(); $this->commit(); + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $this->rollBack(); throw $e; diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php index 650dfc5bcdbb5..adef85115b69c 100644 --- a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php @@ -119,6 +119,8 @@ public function reindexAll() try { $this->_prepareIndexTable(); $this->commit(); + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $this->rollBack(); throw $e; diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Category.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Category.php index e9c0e06ac38a0..59227fb200db7 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Category.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Category.php @@ -48,6 +48,8 @@ private function addCommitCallback(ResourceCategory $resourceCategory, \Closure } }); $resourceCategory->commit(); + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $resourceCategory->rollBack(); throw $e; diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product.php index 949033bb338e0..e4bbcdf048107 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product.php @@ -53,6 +53,8 @@ private function addCommitCallback(ResourceProduct $productResource, \Closure $p $this->reindexRow($product->getEntityId()); }); $productResource->commit(); + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $productResource->rollBack(); throw $e; diff --git a/app/code/Magento/Customer/Model/Plugin/CustomerRepository/TransactionWrapper.php b/app/code/Magento/Customer/Model/Plugin/CustomerRepository/TransactionWrapper.php index 45041b10c9c7b..eeecdd3bb7783 100644 --- a/app/code/Magento/Customer/Model/Plugin/CustomerRepository/TransactionWrapper.php +++ b/app/code/Magento/Customer/Model/Plugin/CustomerRepository/TransactionWrapper.php @@ -44,6 +44,8 @@ public function aroundSave( $result = $proceed($customer, $passwordHash); $this->resourceModel->commit(); return $result; + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $this->resourceModel->rollBack(); throw $e; diff --git a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php index 071f5167b5870..ef0b06b569d65 100644 --- a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php +++ b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php @@ -1142,6 +1142,8 @@ public function save(\Magento\Framework\Model\AbstractModel $object) } $this->addCommitCallback([$object, 'afterCommitCallback'])->commit(); $object->setHasDataChanges(false); + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (DuplicateException $e) { $this->rollBack(); $object->setHasDataChanges(true); diff --git a/app/code/Magento/Eav/Model/Entity/Type.php b/app/code/Magento/Eav/Model/Entity/Type.php index e8f2a30804efd..e29d713530302 100644 --- a/app/code/Magento/Eav/Model/Entity/Type.php +++ b/app/code/Magento/Eav/Model/Entity/Type.php @@ -254,6 +254,8 @@ public function fetchNewIncrementId($storeId = null) // Commit increment_last_id changes $this->_getResource()->commit(); + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $exception) { $this->_getResource()->rollBack(); throw $exception; diff --git a/app/code/Magento/Eav/Model/Entity/VersionControl/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/VersionControl/AbstractEntity.php index 7b44749273e4a..0815d5021f478 100644 --- a/app/code/Magento/Eav/Model/Entity/VersionControl/AbstractEntity.php +++ b/app/code/Magento/Eav/Model/Entity/VersionControl/AbstractEntity.php @@ -97,6 +97,8 @@ public function save(\Magento\Framework\Model\AbstractModel $object) $this->addCommitCallback([$object, 'afterCommitCallback'])->commit(); $object->setHasDataChanges(false); + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $this->rollBack(); $object->setHasDataChanges(true); diff --git a/app/code/Magento/EncryptionKey/Model/ResourceModel/Key/Change.php b/app/code/Magento/EncryptionKey/Model/ResourceModel/Key/Change.php index aaa3551e9e04c..268eda33f7143 100644 --- a/app/code/Magento/EncryptionKey/Model/ResourceModel/Key/Change.php +++ b/app/code/Magento/EncryptionKey/Model/ResourceModel/Key/Change.php @@ -123,6 +123,8 @@ public function changeEncryptionKey($key = null) $this->writer->saveConfig($configData); $this->commit(); return $key; + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $this->rollBack(); throw $e; diff --git a/app/code/Magento/Indexer/Model/ResourceModel/AbstractResource.php b/app/code/Magento/Indexer/Model/ResourceModel/AbstractResource.php index 3294ed5fcaba8..143c53f86af57 100644 --- a/app/code/Magento/Indexer/Model/ResourceModel/AbstractResource.php +++ b/app/code/Magento/Indexer/Model/ResourceModel/AbstractResource.php @@ -89,6 +89,8 @@ public function syncData() $this->getConnection()->delete($this->getMainTable()); $this->insertFromTable($this->getIdxTable(), $this->getMainTable(), false); $this->commit(); + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $this->rollBack(); throw $e; diff --git a/app/code/Magento/Sitemap/Model/ResourceModel/Cms/Page.php b/app/code/Magento/Sitemap/Model/ResourceModel/Cms/Page.php index e542e32b9d75d..fc937c9c94394 100644 --- a/app/code/Magento/Sitemap/Model/ResourceModel/Cms/Page.php +++ b/app/code/Magento/Sitemap/Model/ResourceModel/Cms/Page.php @@ -185,6 +185,8 @@ public function save(AbstractModel $object) } $this->addCommitCallback([$object, 'afterCommitCallback'])->commit(); $object->setHasDataChanges(false); + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $this->rollBack(); $object->setHasDataChanges(true); From 466358112693170d95936ae1c4a80bc1d1ed2b00 Mon Sep 17 00:00:00 2001 From: Wayne Theisinger Date: Wed, 14 Jun 2017 16:19:32 +0100 Subject: [PATCH 05/16] Delete forcing file that was used to nudge travis --- forceBuild.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 forceBuild.txt diff --git a/forceBuild.txt b/forceBuild.txt deleted file mode 100644 index 6dacae433f39f..0000000000000 --- a/forceBuild.txt +++ /dev/null @@ -1 +0,0 @@ -forcing From 465b591f8d03ea4eabb4f1671f37a81ab0301c1a Mon Sep 17 00:00:00 2001 From: waynemowdirect Date: Wed, 14 Jun 2017 17:30:03 +0100 Subject: [PATCH 06/16] Fix Code Style --- .../Magento/Framework/Exception/AfterCommitException.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Exception/AfterCommitException.php b/lib/internal/Magento/Framework/Exception/AfterCommitException.php index 4baa5aaf0d6fe..129e66fe19e7d 100644 --- a/lib/internal/Magento/Framework/Exception/AfterCommitException.php +++ b/lib/internal/Magento/Framework/Exception/AfterCommitException.php @@ -12,4 +12,4 @@ */ class AfterCommitException extends \Exception { -} \ No newline at end of file +} From 7e309677231f2fc5541be7c599bc1cb3144f0f49 Mon Sep 17 00:00:00 2001 From: waynemowdirect Date: Wed, 14 Jun 2017 18:12:29 +0100 Subject: [PATCH 07/16] Suppress CyclomaticComplexity Warning - Discuss with Core Team --- app/code/Magento/Eav/Model/Entity/AbstractEntity.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php index ef0b06b569d65..3a473a130320d 100644 --- a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php +++ b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php @@ -31,6 +31,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ abstract class AbstractEntity extends AbstractResource implements EntityInterface, DefaultAttributesProvider { From 95c2ae9ec4063d0b7452e300e2c824119136a877 Mon Sep 17 00:00:00 2001 From: waynemowdirect Date: Thu, 15 Jun 2017 08:06:26 +0100 Subject: [PATCH 08/16] Alter Tests to add new exception catches (plus a few main catches) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- app/code/Magento/Authorization/Model/ResourceModel/Rules.php | 2 -- app/code/Magento/Sales/Model/Order/Status.php | 2 ++ app/code/Magento/Store/Model/Config/Importer.php | 2 ++ .../testsuite/Magento/Reports/_files/viewed_products.php | 2 ++ .../testsuite/Magento/Sales/_files/report_bestsellers.php | 2 ++ .../testsuite/Magento/Sales/_files/report_invoiced.php | 2 ++ .../testsuite/Magento/Sales/_files/report_refunded.php | 2 ++ .../testsuite/Magento/Sales/_files/report_shipping.php | 2 ++ .../testsuite/Magento/SalesRule/_files/report_coupons.php | 2 ++ .../integration/testsuite/Magento/Tax/_files/report_tax.php | 2 ++ .../Magento/Framework/Model/ResourceModel/Db/AbstractDb.php | 2 ++ 11 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Authorization/Model/ResourceModel/Rules.php b/app/code/Magento/Authorization/Model/ResourceModel/Rules.php index 1ed44f405ccb9..e888b81e002df 100644 --- a/app/code/Magento/Authorization/Model/ResourceModel/Rules.php +++ b/app/code/Magento/Authorization/Model/ResourceModel/Rules.php @@ -121,8 +121,6 @@ public function saveRel(\Magento\Authorization\Model\Rules $rule) $connection->commit(); $this->aclDataCache->clean(); - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Magento\Framework\Exception\LocalizedException $e) { $connection->rollBack(); throw $e; diff --git a/app/code/Magento/Sales/Model/Order/Status.php b/app/code/Magento/Sales/Model/Order/Status.php index bdd15d4d844c6..02ea70b0141a1 100644 --- a/app/code/Magento/Sales/Model/Order/Status.php +++ b/app/code/Magento/Sales/Model/Order/Status.php @@ -77,6 +77,8 @@ public function assignState($state, $isDefault = false, $visibleOnFront = false) try { $resource->assignState($this->getStatus(), $state, $isDefault, $visibleOnFront); $resource->commit(); + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $resource->rollBack(); throw $e; diff --git a/app/code/Magento/Store/Model/Config/Importer.php b/app/code/Magento/Store/Model/Config/Importer.php index 130e523ab53df..f255a471fd74b 100644 --- a/app/code/Magento/Store/Model/Config/Importer.php +++ b/app/code/Magento/Store/Model/Config/Importer.php @@ -105,6 +105,8 @@ public function import(array $data) foreach ($actions as $action) { $this->processFactory->create($action)->run($data); } + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $exception) { $this->resource->rollBack(); $this->reinitStores(); diff --git a/dev/tests/integration/testsuite/Magento/Reports/_files/viewed_products.php b/dev/tests/integration/testsuite/Magento/Reports/_files/viewed_products.php index 3cf81d910cfdf..553890cac86e8 100644 --- a/dev/tests/integration/testsuite/Magento/Reports/_files/viewed_products.php +++ b/dev/tests/integration/testsuite/Magento/Reports/_files/viewed_products.php @@ -54,6 +54,8 @@ try { $reportResource->aggregate(); $reportResource->commit(); +} catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $reportResource->rollBack(); throw $e; diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/report_bestsellers.php b/dev/tests/integration/testsuite/Magento/Sales/_files/report_bestsellers.php index 870bb3195c6dd..580f648c709bf 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/report_bestsellers.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/report_bestsellers.php @@ -14,6 +14,8 @@ try { $reportResource->aggregate(); $reportResource->commit(); +} catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $reportResource->rollBack(); throw $e; diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/report_invoiced.php b/dev/tests/integration/testsuite/Magento/Sales/_files/report_invoiced.php index d75a96c8d7b4b..192ca45d42c10 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/report_invoiced.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/report_invoiced.php @@ -14,6 +14,8 @@ try { $reportResource->aggregate(); $reportResource->commit(); +} catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $reportResource->rollBack(); throw $e; diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/report_refunded.php b/dev/tests/integration/testsuite/Magento/Sales/_files/report_refunded.php index 34a83de03747b..57c81b623dabd 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/report_refunded.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/report_refunded.php @@ -14,6 +14,8 @@ try { $reportResource->aggregate(); $reportResource->commit(); +} catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $reportResource->rollBack(); throw $e; diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/report_shipping.php b/dev/tests/integration/testsuite/Magento/Sales/_files/report_shipping.php index c2411fbf02049..a48758a164412 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/report_shipping.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/report_shipping.php @@ -14,6 +14,8 @@ try { $reportResource->aggregate(); $reportResource->commit(); +} catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $reportResource->rollBack(); throw $e; diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/_files/report_coupons.php b/dev/tests/integration/testsuite/Magento/SalesRule/_files/report_coupons.php index 21222e3bd26ab..5059bee84d0ea 100644 --- a/dev/tests/integration/testsuite/Magento/SalesRule/_files/report_coupons.php +++ b/dev/tests/integration/testsuite/Magento/SalesRule/_files/report_coupons.php @@ -14,6 +14,8 @@ try { $reportResource->aggregate(); $reportResource->commit(); +} catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $reportResource->rollBack(); throw $e; diff --git a/dev/tests/integration/testsuite/Magento/Tax/_files/report_tax.php b/dev/tests/integration/testsuite/Magento/Tax/_files/report_tax.php index c4b22617bbd5c..080b48f19711e 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/_files/report_tax.php +++ b/dev/tests/integration/testsuite/Magento/Tax/_files/report_tax.php @@ -13,6 +13,8 @@ try { $reportResource->aggregate(); $reportResource->commit(); +} catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Exception $e) { $reportResource->rollBack(); throw $e; diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php index 01bfed5059553..30f35ee32e941 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php @@ -419,6 +419,8 @@ public function save(\Magento\Framework\Model\AbstractModel $object) } $this->addCommitCallback([$object, 'afterCommitCallback'])->commit(); $object->setHasDataChanges(false); + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (DuplicateException $e) { $this->rollBack(); $object->setHasDataChanges(true); From 0d421334d151a568d218ffeca0fa0cf2dba289d1 Mon Sep 17 00:00:00 2001 From: waynemowdirect Date: Thu, 15 Jun 2017 08:06:26 +0100 Subject: [PATCH 09/16] Revert "Alter Tests to add new exception catches (plus a few main catches)" This reverts commit 95c2ae9ec4063d0b7452e300e2c824119136a877. --- app/code/Magento/Authorization/Model/ResourceModel/Rules.php | 2 ++ app/code/Magento/Sales/Model/Order/Status.php | 2 -- app/code/Magento/Store/Model/Config/Importer.php | 2 -- .../testsuite/Magento/Reports/_files/viewed_products.php | 2 -- .../testsuite/Magento/Sales/_files/report_bestsellers.php | 2 -- .../testsuite/Magento/Sales/_files/report_invoiced.php | 2 -- .../testsuite/Magento/Sales/_files/report_refunded.php | 2 -- .../testsuite/Magento/Sales/_files/report_shipping.php | 2 -- .../testsuite/Magento/SalesRule/_files/report_coupons.php | 2 -- .../integration/testsuite/Magento/Tax/_files/report_tax.php | 2 -- .../Magento/Framework/Model/ResourceModel/Db/AbstractDb.php | 2 -- 11 files changed, 2 insertions(+), 20 deletions(-) diff --git a/app/code/Magento/Authorization/Model/ResourceModel/Rules.php b/app/code/Magento/Authorization/Model/ResourceModel/Rules.php index e888b81e002df..1ed44f405ccb9 100644 --- a/app/code/Magento/Authorization/Model/ResourceModel/Rules.php +++ b/app/code/Magento/Authorization/Model/ResourceModel/Rules.php @@ -121,6 +121,8 @@ public function saveRel(\Magento\Authorization\Model\Rules $rule) $connection->commit(); $this->aclDataCache->clean(); + } catch (\Magento\Framework\Exception\AfterCommitException $e) { + throw $e->getPrevious(); } catch (\Magento\Framework\Exception\LocalizedException $e) { $connection->rollBack(); throw $e; diff --git a/app/code/Magento/Sales/Model/Order/Status.php b/app/code/Magento/Sales/Model/Order/Status.php index 02ea70b0141a1..bdd15d4d844c6 100644 --- a/app/code/Magento/Sales/Model/Order/Status.php +++ b/app/code/Magento/Sales/Model/Order/Status.php @@ -77,8 +77,6 @@ public function assignState($state, $isDefault = false, $visibleOnFront = false) try { $resource->assignState($this->getStatus(), $state, $isDefault, $visibleOnFront); $resource->commit(); - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $resource->rollBack(); throw $e; diff --git a/app/code/Magento/Store/Model/Config/Importer.php b/app/code/Magento/Store/Model/Config/Importer.php index f255a471fd74b..130e523ab53df 100644 --- a/app/code/Magento/Store/Model/Config/Importer.php +++ b/app/code/Magento/Store/Model/Config/Importer.php @@ -105,8 +105,6 @@ public function import(array $data) foreach ($actions as $action) { $this->processFactory->create($action)->run($data); } - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $exception) { $this->resource->rollBack(); $this->reinitStores(); diff --git a/dev/tests/integration/testsuite/Magento/Reports/_files/viewed_products.php b/dev/tests/integration/testsuite/Magento/Reports/_files/viewed_products.php index 553890cac86e8..3cf81d910cfdf 100644 --- a/dev/tests/integration/testsuite/Magento/Reports/_files/viewed_products.php +++ b/dev/tests/integration/testsuite/Magento/Reports/_files/viewed_products.php @@ -54,8 +54,6 @@ try { $reportResource->aggregate(); $reportResource->commit(); -} catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $reportResource->rollBack(); throw $e; diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/report_bestsellers.php b/dev/tests/integration/testsuite/Magento/Sales/_files/report_bestsellers.php index 580f648c709bf..870bb3195c6dd 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/report_bestsellers.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/report_bestsellers.php @@ -14,8 +14,6 @@ try { $reportResource->aggregate(); $reportResource->commit(); -} catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $reportResource->rollBack(); throw $e; diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/report_invoiced.php b/dev/tests/integration/testsuite/Magento/Sales/_files/report_invoiced.php index 192ca45d42c10..d75a96c8d7b4b 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/report_invoiced.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/report_invoiced.php @@ -14,8 +14,6 @@ try { $reportResource->aggregate(); $reportResource->commit(); -} catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $reportResource->rollBack(); throw $e; diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/report_refunded.php b/dev/tests/integration/testsuite/Magento/Sales/_files/report_refunded.php index 57c81b623dabd..34a83de03747b 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/report_refunded.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/report_refunded.php @@ -14,8 +14,6 @@ try { $reportResource->aggregate(); $reportResource->commit(); -} catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $reportResource->rollBack(); throw $e; diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/report_shipping.php b/dev/tests/integration/testsuite/Magento/Sales/_files/report_shipping.php index a48758a164412..c2411fbf02049 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/report_shipping.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/report_shipping.php @@ -14,8 +14,6 @@ try { $reportResource->aggregate(); $reportResource->commit(); -} catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $reportResource->rollBack(); throw $e; diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/_files/report_coupons.php b/dev/tests/integration/testsuite/Magento/SalesRule/_files/report_coupons.php index 5059bee84d0ea..21222e3bd26ab 100644 --- a/dev/tests/integration/testsuite/Magento/SalesRule/_files/report_coupons.php +++ b/dev/tests/integration/testsuite/Magento/SalesRule/_files/report_coupons.php @@ -14,8 +14,6 @@ try { $reportResource->aggregate(); $reportResource->commit(); -} catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $reportResource->rollBack(); throw $e; diff --git a/dev/tests/integration/testsuite/Magento/Tax/_files/report_tax.php b/dev/tests/integration/testsuite/Magento/Tax/_files/report_tax.php index 080b48f19711e..c4b22617bbd5c 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/_files/report_tax.php +++ b/dev/tests/integration/testsuite/Magento/Tax/_files/report_tax.php @@ -13,8 +13,6 @@ try { $reportResource->aggregate(); $reportResource->commit(); -} catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $reportResource->rollBack(); throw $e; diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php index 30f35ee32e941..01bfed5059553 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php @@ -419,8 +419,6 @@ public function save(\Magento\Framework\Model\AbstractModel $object) } $this->addCommitCallback([$object, 'afterCommitCallback'])->commit(); $object->setHasDataChanges(false); - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (DuplicateException $e) { $this->rollBack(); $object->setHasDataChanges(true); From d1b891afdddbd4dac8334f6f34527b9bf38547c5 Mon Sep 17 00:00:00 2001 From: waynemowdirect Date: Wed, 14 Jun 2017 18:12:29 +0100 Subject: [PATCH 10/16] Revert "Suppress CyclomaticComplexity Warning - Discuss with Core Team" This reverts commit 7e309677231f2fc5541be7c599bc1cb3144f0f49. --- app/code/Magento/Eav/Model/Entity/AbstractEntity.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php index 3a473a130320d..ef0b06b569d65 100644 --- a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php +++ b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php @@ -31,7 +31,6 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ abstract class AbstractEntity extends AbstractResource implements EntityInterface, DefaultAttributesProvider { From 7b813c2958790c68636bc09d0ff1d64c57bfa165 Mon Sep 17 00:00:00 2001 From: waynemowdirect Date: Wed, 14 Jun 2017 17:30:03 +0100 Subject: [PATCH 11/16] Revert "Fix Code Style" This reverts commit 465b591f8d03ea4eabb4f1671f37a81ab0301c1a. --- .../Magento/Framework/Exception/AfterCommitException.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Exception/AfterCommitException.php b/lib/internal/Magento/Framework/Exception/AfterCommitException.php index 129e66fe19e7d..4baa5aaf0d6fe 100644 --- a/lib/internal/Magento/Framework/Exception/AfterCommitException.php +++ b/lib/internal/Magento/Framework/Exception/AfterCommitException.php @@ -12,4 +12,4 @@ */ class AfterCommitException extends \Exception { -} +} \ No newline at end of file From b672c4e428f436eb87128b1f97ce2b9b26f7142c Mon Sep 17 00:00:00 2001 From: waynemowdirect Date: Wed, 14 Jun 2017 16:12:32 +0100 Subject: [PATCH 12/16] Revert "Catch AfterCommitException from AbstractResource.php" This reverts commit 1cc3787e4c446dfa65af9d06d754208da1b816b7. --- .../Magento/Authorization/Model/ResourceModel/Rules.php | 2 -- .../Catalog/Console/Command/ProductAttributesCleanUp.php | 2 -- app/code/Magento/Catalog/Model/Category.php | 2 -- .../Model/Plugin/ProductRepository/TransactionWrapper.php | 6 ------ .../Model/ResourceModel/Product/Indexer/Eav/AbstractEav.php | 2 -- .../ResourceModel/Product/Indexer/Price/DefaultPrice.php | 2 -- .../Model/ResourceModel/Indexer/Stock/DefaultStock.php | 2 -- .../Model/Indexer/Fulltext/Plugin/Category.php | 2 -- .../CatalogSearch/Model/Indexer/Fulltext/Plugin/Product.php | 2 -- .../Model/Plugin/CustomerRepository/TransactionWrapper.php | 2 -- app/code/Magento/Eav/Model/Entity/AbstractEntity.php | 2 -- app/code/Magento/Eav/Model/Entity/Type.php | 2 -- .../Eav/Model/Entity/VersionControl/AbstractEntity.php | 2 -- .../EncryptionKey/Model/ResourceModel/Key/Change.php | 2 -- .../Indexer/Model/ResourceModel/AbstractResource.php | 2 -- app/code/Magento/Sitemap/Model/ResourceModel/Cms/Page.php | 2 -- 16 files changed, 36 deletions(-) diff --git a/app/code/Magento/Authorization/Model/ResourceModel/Rules.php b/app/code/Magento/Authorization/Model/ResourceModel/Rules.php index 1ed44f405ccb9..e888b81e002df 100644 --- a/app/code/Magento/Authorization/Model/ResourceModel/Rules.php +++ b/app/code/Magento/Authorization/Model/ResourceModel/Rules.php @@ -121,8 +121,6 @@ public function saveRel(\Magento\Authorization\Model\Rules $rule) $connection->commit(); $this->aclDataCache->clean(); - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Magento\Framework\Exception\LocalizedException $e) { $connection->rollBack(); throw $e; diff --git a/app/code/Magento/Catalog/Console/Command/ProductAttributesCleanUp.php b/app/code/Magento/Catalog/Console/Command/ProductAttributesCleanUp.php index 0291f0ba6921a..4fc63d1d662c0 100644 --- a/app/code/Magento/Catalog/Console/Command/ProductAttributesCleanUp.php +++ b/app/code/Magento/Catalog/Console/Command/ProductAttributesCleanUp.php @@ -102,8 +102,6 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln("Unused product attributes successfully cleaned up:"); $output->writeln(" " . implode("\n ", $attributeTables) . ""); return \Magento\Framework\Console\Cli::RETURN_SUCCESS; - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $exception) { $this->attributeResource->rollBack(); diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php index 833e26be706cc..311bd4f9422fd 100644 --- a/app/code/Magento/Catalog/Model/Category.php +++ b/app/code/Magento/Catalog/Model/Category.php @@ -429,8 +429,6 @@ public function move($parentId, $afterCategoryId) // Set data for indexer $this->setAffectedCategoryIds([$this->getId(), $oldParentId, $parentId]); - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $this->_getResource()->rollBack(); throw $e; diff --git a/app/code/Magento/Catalog/Model/Plugin/ProductRepository/TransactionWrapper.php b/app/code/Magento/Catalog/Model/Plugin/ProductRepository/TransactionWrapper.php index c437e2220844a..c88215d92357e 100644 --- a/app/code/Magento/Catalog/Model/Plugin/ProductRepository/TransactionWrapper.php +++ b/app/code/Magento/Catalog/Model/Plugin/ProductRepository/TransactionWrapper.php @@ -44,8 +44,6 @@ public function aroundSave( $result = $proceed($product, $saveOptions); $this->resourceModel->commit(); return $result; - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $this->resourceModel->rollBack(); throw $e; @@ -71,8 +69,6 @@ public function aroundDelete( $result = $proceed($product); $this->resourceModel->commit(); return $result; - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $this->resourceModel->rollBack(); throw $e; @@ -98,8 +94,6 @@ public function aroundDeleteById( $result = $proceed($productSku); $this->resourceModel->commit(); return $result; - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $this->resourceModel->rollBack(); throw $e; diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/AbstractEav.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/AbstractEav.php index 3bdf244077b8a..8f4a47804c8ae 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/AbstractEav.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/AbstractEav.php @@ -77,8 +77,6 @@ public function reindexAll() $this->_removeNotVisibleEntityFromIndex(); $this->syncData(); $this->commit(); - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $this->rollBack(); throw $e; diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index dca51a181ef89..a613690209432 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -167,8 +167,6 @@ public function reindexAll() try { $this->reindex(); $this->commit(); - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $this->rollBack(); throw $e; diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php index adef85115b69c..650dfc5bcdbb5 100644 --- a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php @@ -119,8 +119,6 @@ public function reindexAll() try { $this->_prepareIndexTable(); $this->commit(); - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $this->rollBack(); throw $e; diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Category.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Category.php index 59227fb200db7..e9c0e06ac38a0 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Category.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Category.php @@ -48,8 +48,6 @@ private function addCommitCallback(ResourceCategory $resourceCategory, \Closure } }); $resourceCategory->commit(); - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $resourceCategory->rollBack(); throw $e; diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product.php index e4bbcdf048107..949033bb338e0 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product.php @@ -53,8 +53,6 @@ private function addCommitCallback(ResourceProduct $productResource, \Closure $p $this->reindexRow($product->getEntityId()); }); $productResource->commit(); - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $productResource->rollBack(); throw $e; diff --git a/app/code/Magento/Customer/Model/Plugin/CustomerRepository/TransactionWrapper.php b/app/code/Magento/Customer/Model/Plugin/CustomerRepository/TransactionWrapper.php index eeecdd3bb7783..45041b10c9c7b 100644 --- a/app/code/Magento/Customer/Model/Plugin/CustomerRepository/TransactionWrapper.php +++ b/app/code/Magento/Customer/Model/Plugin/CustomerRepository/TransactionWrapper.php @@ -44,8 +44,6 @@ public function aroundSave( $result = $proceed($customer, $passwordHash); $this->resourceModel->commit(); return $result; - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $this->resourceModel->rollBack(); throw $e; diff --git a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php index ef0b06b569d65..071f5167b5870 100644 --- a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php +++ b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php @@ -1142,8 +1142,6 @@ public function save(\Magento\Framework\Model\AbstractModel $object) } $this->addCommitCallback([$object, 'afterCommitCallback'])->commit(); $object->setHasDataChanges(false); - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (DuplicateException $e) { $this->rollBack(); $object->setHasDataChanges(true); diff --git a/app/code/Magento/Eav/Model/Entity/Type.php b/app/code/Magento/Eav/Model/Entity/Type.php index e29d713530302..e8f2a30804efd 100644 --- a/app/code/Magento/Eav/Model/Entity/Type.php +++ b/app/code/Magento/Eav/Model/Entity/Type.php @@ -254,8 +254,6 @@ public function fetchNewIncrementId($storeId = null) // Commit increment_last_id changes $this->_getResource()->commit(); - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $exception) { $this->_getResource()->rollBack(); throw $exception; diff --git a/app/code/Magento/Eav/Model/Entity/VersionControl/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/VersionControl/AbstractEntity.php index 0815d5021f478..7b44749273e4a 100644 --- a/app/code/Magento/Eav/Model/Entity/VersionControl/AbstractEntity.php +++ b/app/code/Magento/Eav/Model/Entity/VersionControl/AbstractEntity.php @@ -97,8 +97,6 @@ public function save(\Magento\Framework\Model\AbstractModel $object) $this->addCommitCallback([$object, 'afterCommitCallback'])->commit(); $object->setHasDataChanges(false); - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $this->rollBack(); $object->setHasDataChanges(true); diff --git a/app/code/Magento/EncryptionKey/Model/ResourceModel/Key/Change.php b/app/code/Magento/EncryptionKey/Model/ResourceModel/Key/Change.php index 268eda33f7143..aaa3551e9e04c 100644 --- a/app/code/Magento/EncryptionKey/Model/ResourceModel/Key/Change.php +++ b/app/code/Magento/EncryptionKey/Model/ResourceModel/Key/Change.php @@ -123,8 +123,6 @@ public function changeEncryptionKey($key = null) $this->writer->saveConfig($configData); $this->commit(); return $key; - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $this->rollBack(); throw $e; diff --git a/app/code/Magento/Indexer/Model/ResourceModel/AbstractResource.php b/app/code/Magento/Indexer/Model/ResourceModel/AbstractResource.php index 143c53f86af57..3294ed5fcaba8 100644 --- a/app/code/Magento/Indexer/Model/ResourceModel/AbstractResource.php +++ b/app/code/Magento/Indexer/Model/ResourceModel/AbstractResource.php @@ -89,8 +89,6 @@ public function syncData() $this->getConnection()->delete($this->getMainTable()); $this->insertFromTable($this->getIdxTable(), $this->getMainTable(), false); $this->commit(); - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $this->rollBack(); throw $e; diff --git a/app/code/Magento/Sitemap/Model/ResourceModel/Cms/Page.php b/app/code/Magento/Sitemap/Model/ResourceModel/Cms/Page.php index fc937c9c94394..e542e32b9d75d 100644 --- a/app/code/Magento/Sitemap/Model/ResourceModel/Cms/Page.php +++ b/app/code/Magento/Sitemap/Model/ResourceModel/Cms/Page.php @@ -185,8 +185,6 @@ public function save(AbstractModel $object) } $this->addCommitCallback([$object, 'afterCommitCallback'])->commit(); $object->setHasDataChanges(false); - } catch (\Magento\Framework\Exception\AfterCommitException $e) { - throw $e->getPrevious(); } catch (\Exception $e) { $this->rollBack(); $object->setHasDataChanges(true); From 12631c0e3f5cab73ce6bc2caf444b5078b31a27d Mon Sep 17 00:00:00 2001 From: waynemowdirect Date: Wed, 14 Jun 2017 13:49:56 +0100 Subject: [PATCH 13/16] Revert "Throw new AfterCommitException from AbstractResource.php" This reverts commit 69706119fdd1911dc9412211a4b3f89132019549. --- .../Magento/Framework/Model/ResourceModel/AbstractResource.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php b/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php index 90cc88bfc0817..1e3de56f495bf 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php @@ -9,7 +9,6 @@ use Magento\Framework\DataObject; use Magento\Framework\Model\CallbackPool; use Magento\Framework\Serialize\Serializer\Json; -use Magento\Framework\Exception\AfterCommitException; /** * Abstract resource model @@ -92,7 +91,7 @@ public function commit() call_user_func($callback); } } catch (\Exception $e) { - throw new AfterCommitException(null, null, $e); + throw $e; } } return $this; From 0c886cafbc9087f85c529d1da689f1ed530aaf58 Mon Sep 17 00:00:00 2001 From: waynemowdirect Date: Wed, 14 Jun 2017 12:36:49 +0100 Subject: [PATCH 14/16] Revert "Add AfterCommitException" This reverts commit f0b320b75757eb9f78c56cee057e0bfa990ebe0d. --- .../Framework/Exception/AfterCommitException.php | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 lib/internal/Magento/Framework/Exception/AfterCommitException.php diff --git a/lib/internal/Magento/Framework/Exception/AfterCommitException.php b/lib/internal/Magento/Framework/Exception/AfterCommitException.php deleted file mode 100644 index 4baa5aaf0d6fe..0000000000000 --- a/lib/internal/Magento/Framework/Exception/AfterCommitException.php +++ /dev/null @@ -1,15 +0,0 @@ - Date: Fri, 7 Jul 2017 16:06:14 +0100 Subject: [PATCH 15/16] Instead of throwing exception - just log MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a callback in commit throws an excecption, we mustn't attempt a rollback on an already commited transaction. (Which would cause an “Asymmetric transaction rollback" error) - so rather than throwing the exception we will just log it. --- .../Magento/Framework/Model/ResourceModel/AbstractResource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php b/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php index 1e3de56f495bf..408a07f3e0db5 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php @@ -91,7 +91,7 @@ public function commit() call_user_func($callback); } } catch (\Exception $e) { - throw $e; + $this->logger->critical($e); } } return $this; From 6caed913099065eb133891a51c6e87b5640a2064 Mon Sep 17 00:00:00 2001 From: Nolwennig Guilbert Date: Mon, 10 Jul 2017 17:25:51 +0200 Subject: [PATCH 16/16] Update max length for attribute_code (30 to 255) According with 'attribute_code' (size 255) see in https://github.com/magento/magento2/blob/develop/app/code/Magento/Eav/Setup/InstallSchema.php#L644 , I update the ATTRIBUTE_CODE_MAX_LENGTH constant value from 30 to 255; --- app/code/Magento/Eav/Model/Entity/Attribute.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Eav/Model/Entity/Attribute.php b/app/code/Magento/Eav/Model/Entity/Attribute.php index fc598b264b395..8df61d5969a2a 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute.php @@ -23,7 +23,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute im /** * Attribute code max length */ - const ATTRIBUTE_CODE_MAX_LENGTH = 30; + const ATTRIBUTE_CODE_MAX_LENGTH = 255; /** * Cache tag