From 9ae5c46c013a62c2d0fafc81556b6c5807a32183 Mon Sep 17 00:00:00 2001 From: Igor Wulff Date: Mon, 9 Dec 2024 13:38:32 +0100 Subject: [PATCH] Typecast incrementId variables always to a string Ensure our calls to the sales_order table for the increment_id field are called with a string type and not an int type. When a module passed through an int variable, a full table scan occurs since the increment_id index can not be utilized. --- app/code/Magento/Sales/Model/Order.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index 1d1b926a1a24c..b9d66818e8f9c 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -559,7 +559,7 @@ public function setCanSendNewEmailFlag($flag) */ public function loadByIncrementId($incrementId) { - return $this->loadByAttribute('increment_id', $incrementId); + return $this->loadByAttribute('increment_id', (string) $incrementId); } /** @@ -573,7 +573,7 @@ public function loadByIncrementIdAndStoreId($incrementId, $storeId) { $orderCollection = $this->getSalesOrderCollection( [ - 'increment_id' => $incrementId, + 'increment_id' => (string) $incrementId, 'store_id' => $storeId ] );