From bec5c0ada8d8471b0d0be8816c50243721349afa Mon Sep 17 00:00:00 2001 From: Tymoteusz Motylewski Date: Mon, 6 Apr 2020 14:16:57 +0200 Subject: [PATCH] Make oldFields mapping hardcoded to speed up system The mapping came with Magneto 1.6 to provide a backward compatibility for old (pre 1.6) db field names. Now the mapping is hardcoded in the class instead of saved in the configuration. This improves performance as Magento will not create tons of objects for every new product/order/... entities. Related: https://github.com/OpenMage/magento-lts/issues/920 --- README.md | 1 + app/code/core/Mage/Catalog/Model/Product.php | 1 - .../core/Mage/CatalogInventory/Model/Stock/Item.php | 1 + app/code/core/Mage/Sales/Model/Order.php | 7 ++++++- app/code/core/Mage/Sales/Model/Order/Address.php | 1 - app/code/core/Mage/Sales/Model/Order/Creditmemo.php | 1 - .../core/Mage/Sales/Model/Order/Creditmemo/Item.php | 5 ++++- app/code/core/Mage/Sales/Model/Order/Invoice.php | 1 - app/code/core/Mage/Sales/Model/Order/Invoice/Item.php | 5 ++++- app/code/core/Mage/Sales/Model/Order/Item.php | 5 ++++- app/code/core/Mage/Sales/Model/Order/Shipment.php | 1 - app/code/core/Mage/Sales/Model/Quote.php | 1 - app/code/core/Mage/Sales/Model/Quote/Address.php | 1 - app/code/core/Mage/Sales/Model/Quote/Item.php | 1 - app/code/core/Mage/Sales/etc/config.xml | 7 ------- app/code/core/Mage/Weee/etc/config.xml | 11 ----------- 16 files changed, 20 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 3930bf0cd22..e409ae8e648 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ Do not use 20.x.x if you need IE support. - add redis as a valid option for `global/session_save` #1513 - possibility to disable global search in backend #1532 - reduce needless saves by avoiding setting `_hasDataChanges` flag #2066 +- removed support for `global/sales/old_fields_map` defined in XML #921 For full list of changes, you can [compare tags](https://github.com/OpenMage/magento-lts/compare/1.9.4.x...20.0). diff --git a/app/code/core/Mage/Catalog/Model/Product.php b/app/code/core/Mage/Catalog/Model/Product.php index 03b59086312..a3f3875948b 100644 --- a/app/code/core/Mage/Catalog/Model/Product.php +++ b/app/code/core/Mage/Catalog/Model/Product.php @@ -362,7 +362,6 @@ protected function _construct() */ protected function _initOldFieldsMap() { - $this->_oldFieldsMap = Mage::helper('catalog')->getOldFieldMap(); return $this; } diff --git a/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php b/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php index eb54bd5e7cf..5dbef74b415 100644 --- a/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php +++ b/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php @@ -177,6 +177,7 @@ protected function _construct() */ protected function _initOldFieldsMap() { + // pre 1.6 fields names, old => new $this->_oldFieldsMap = array( 'stock_status_changed_automatically' => 'stock_status_changed_auto', 'use_config_enable_qty_increments' => 'use_config_enable_qty_inc' diff --git a/app/code/core/Mage/Sales/Model/Order.php b/app/code/core/Mage/Sales/Model/Order.php index ad23b81ec2b..3fa9ab22c51 100644 --- a/app/code/core/Mage/Sales/Model/Order.php +++ b/app/code/core/Mage/Sales/Model/Order.php @@ -526,7 +526,12 @@ protected function _construct() */ protected function _initOldFieldsMap() { - $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order'); + // pre 1.6 fields names, old => new + $this->_oldFieldsMap = [ + 'payment_authorization_expiration' => 'payment_auth_expiration', + 'forced_do_shipment_with_invoice' => 'forced_shipment_with_invoice', + 'base_shipping_hidden_tax_amount' => 'base_shipping_hidden_tax_amnt', + ]; return $this; } diff --git a/app/code/core/Mage/Sales/Model/Order/Address.php b/app/code/core/Mage/Sales/Model/Order/Address.php index 8b259debf63..cd9dddc41cc 100644 --- a/app/code/core/Mage/Sales/Model/Order/Address.php +++ b/app/code/core/Mage/Sales/Model/Order/Address.php @@ -112,7 +112,6 @@ protected function _construct() */ protected function _initOldFieldsMap() { - $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_address'); return $this; } diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php index f6743a80d14..91f1c0fbbf9 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo.php @@ -224,7 +224,6 @@ protected function _construct() */ protected function _initOldFieldsMap() { - $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_creditmemo'); return $this; } diff --git a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php index 7cae8b9405c..0cebb04ba63 100644 --- a/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php +++ b/app/code/core/Mage/Sales/Model/Order/Creditmemo/Item.php @@ -153,7 +153,10 @@ public function setCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo) */ protected function _initOldFieldsMap() { - $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('creditmemo_item'); + // pre 1.6 fields names, old => new + $this->_oldFieldsMap = [ + 'base_weee_tax_applied_row_amount' => 'base_weee_tax_applied_row_amnt', + ]; return $this; } diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice.php b/app/code/core/Mage/Sales/Model/Order/Invoice.php index e1b6ffd51da..fccd1718753 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice.php @@ -223,7 +223,6 @@ protected function _construct() */ protected function _initOldFieldsMap() { - $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_invoice'); return $this; } diff --git a/app/code/core/Mage/Sales/Model/Order/Invoice/Item.php b/app/code/core/Mage/Sales/Model/Order/Invoice/Item.php index f931beaa9a4..cac7347c837 100644 --- a/app/code/core/Mage/Sales/Model/Order/Invoice/Item.php +++ b/app/code/core/Mage/Sales/Model/Order/Invoice/Item.php @@ -125,7 +125,10 @@ public function _construct() */ protected function _initOldFieldsMap() { - $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('invoice_item'); + // pre 1.6 fields names, old => new + $this->_oldFieldsMap = [ + 'base_weee_tax_applied_row_amount' => 'base_weee_tax_applied_row_amnt', + ]; return $this; } /** diff --git a/app/code/core/Mage/Sales/Model/Order/Item.php b/app/code/core/Mage/Sales/Model/Order/Item.php index 33627c6aa90..0e6f85caaeb 100644 --- a/app/code/core/Mage/Sales/Model/Order/Item.php +++ b/app/code/core/Mage/Sales/Model/Order/Item.php @@ -246,7 +246,10 @@ protected function _construct() */ protected function _initOldFieldsMap() { - $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_item'); + // pre 1.6 fields names, old => new + $this->_oldFieldsMap = [ + 'base_weee_tax_applied_row_amount' => 'base_weee_tax_applied_row_amnt', + ]; return $this; } diff --git a/app/code/core/Mage/Sales/Model/Order/Shipment.php b/app/code/core/Mage/Sales/Model/Order/Shipment.php index 22057b2e946..f0eb59b4248 100644 --- a/app/code/core/Mage/Sales/Model/Order/Shipment.php +++ b/app/code/core/Mage/Sales/Model/Order/Shipment.php @@ -127,7 +127,6 @@ protected function _construct() */ protected function _initOldFieldsMap() { - $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('order_shipment'); return $this; } diff --git a/app/code/core/Mage/Sales/Model/Quote.php b/app/code/core/Mage/Sales/Model/Quote.php index 55ce1a5acb1..b9b8bdd2c5c 100644 --- a/app/code/core/Mage/Sales/Model/Quote.php +++ b/app/code/core/Mage/Sales/Model/Quote.php @@ -262,7 +262,6 @@ protected function _construct() */ protected function _initOldFieldsMap() { - $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('quote'); return $this; } diff --git a/app/code/core/Mage/Sales/Model/Quote/Address.php b/app/code/core/Mage/Sales/Model/Quote/Address.php index d8e7bf741c2..7fe6002d775 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Address.php +++ b/app/code/core/Mage/Sales/Model/Quote/Address.php @@ -321,7 +321,6 @@ protected function _construct() */ protected function _initOldFieldsMap() { - $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('quote_address'); return $this; } diff --git a/app/code/core/Mage/Sales/Model/Quote/Item.php b/app/code/core/Mage/Sales/Model/Quote/Item.php index 72b19e1bbb3..a3d0c7bb2d9 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Item.php +++ b/app/code/core/Mage/Sales/Model/Quote/Item.php @@ -247,7 +247,6 @@ protected function _construct() */ protected function _initOldFieldsMap() { - $this->_oldFieldsMap = Mage::helper('sales')->getOldFieldMap('quote_item'); return $this; } diff --git a/app/code/core/Mage/Sales/etc/config.xml b/app/code/core/Mage/Sales/etc/config.xml index c83e510ade0..b62cf944a4e 100644 --- a/app/code/core/Mage/Sales/etc/config.xml +++ b/app/code/core/Mage/Sales/etc/config.xml @@ -1198,13 +1198,6 @@ - - - payment_auth_expiration - forced_shipment_with_invoice - base_shipping_hidden_tax_amnt - - diff --git a/app/code/core/Mage/Weee/etc/config.xml b/app/code/core/Mage/Weee/etc/config.xml index af8fa12125b..7c9f74c1fdd 100644 --- a/app/code/core/Mage/Weee/etc/config.xml +++ b/app/code/core/Mage/Weee/etc/config.xml @@ -225,17 +225,6 @@ - - - base_weee_tax_applied_row_amnt - - - base_weee_tax_applied_row_amnt - - - base_weee_tax_applied_row_amnt - -