From 800177039504b2e37b2f9642eea0a8dcb1826727 Mon Sep 17 00:00:00 2001 From: kyrena <78410399+kyrena@users.noreply.github.com> Date: Mon, 19 Jun 2023 19:18:54 +0200 Subject: [PATCH 1/3] Fixed passing null for trim is deprecated in Mage_Catalog_Model_Resource_Category_Flat (#3331) --- .../Catalog/Model/Resource/Category/Flat.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php b/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php index 8256201bd8d..13d86cddb17 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php @@ -31,56 +31,56 @@ class Mage_Catalog_Model_Resource_Category_Flat extends Mage_Index_Model_Resourc * * @var int|null */ - protected $_storeId = null; + protected $_storeId = null; /** * Loaded * * @var bool */ - protected $_loaded = false; + protected $_loaded = false; /** * Nodes * * @var array */ - protected $_nodes = []; + protected $_nodes = []; /** * Columns * * @var array */ - protected $_columns = null; + protected $_columns = null; /** * Columns sql * * @var array */ - protected $_columnsSql = null; + protected $_columnsSql = null; /** * Attribute codes * * @var array */ - protected $_attributeCodes = null; + protected $_attributeCodes = null; /** * Inactive categories ids * * @var array */ - protected $_inactiveCategoryIds = null; + protected $_inactiveCategoryIds = null; /** * Store flag which defines if Catalog Category Flat Data has been initialized * * @var array */ - protected $_isBuilt = []; + protected $_isBuilt = []; /** * Store flag which defines if Catalog Category Flat Data has been initialized @@ -89,7 +89,7 @@ class Mage_Catalog_Model_Resource_Category_Flat extends Mage_Index_Model_Resourc * * @var bool|null */ - protected $_isRebuilt = null; + protected $_isRebuilt = null; /** * array with root category id per store @@ -103,7 +103,7 @@ class Mage_Catalog_Model_Resource_Category_Flat extends Mage_Index_Model_Resourc * * @var bool */ - protected $_allowTableChanges = true; + protected $_allowTableChanges = true; /** * Factory instance @@ -658,7 +658,7 @@ protected function _getStaticColumns() } $_is_unsigned = ''; $ddlType = $helper->getDdlTypeByColumnType($column['DATA_TYPE']); - $column['DEFAULT'] = trim($column['DEFAULT'], "' "); + $column['DEFAULT'] = empty($column['DEFAULT']) ? $column['DEFAULT'] : trim($column['DEFAULT'], "' "); switch ($ddlType) { case Varien_Db_Ddl_Table::TYPE_SMALLINT: case Varien_Db_Ddl_Table::TYPE_INTEGER: From bda0b6f3fe253abf0188fa3a02f1dcd7d7c9a4d8 Mon Sep 17 00:00:00 2001 From: kyrena <78410399+kyrena@users.noreply.github.com> Date: Tue, 20 Jun 2023 12:42:15 +0200 Subject: [PATCH 2/3] Fixed passing null for unserialize is deprecated in Mage_Sales_Model_Quote_Address (#3337) --- app/code/core/Mage/Sales/Model/Quote/Address.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/core/Mage/Sales/Model/Quote/Address.php b/app/code/core/Mage/Sales/Model/Quote/Address.php index b3ca22dc0b2..7acfd689fc0 100644 --- a/app/code/core/Mage/Sales/Model/Quote/Address.php +++ b/app/code/core/Mage/Sales/Model/Quote/Address.php @@ -1167,8 +1167,12 @@ public function validateMinimumAmount() */ public function getAppliedTaxes() { + $tax = $this->getData('applied_taxes'); + if (empty($tax)) { + return []; + } try { - $return = Mage::helper('core/unserializeArray')->unserialize($this->getData('applied_taxes')); + $return = Mage::helper('core/unserializeArray')->unserialize($tax); } catch (Exception $e) { $return = []; } From 9b8ededd7b4cbfbb528ddd1cd3c77c84416f88ee Mon Sep 17 00:00:00 2001 From: Ng Kiat Siong Date: Wed, 21 Jun 2023 17:52:00 +0800 Subject: [PATCH 3/3] Fixed "passing null to parameter" in Mage_Core_Helper_String (#3341) --- app/code/core/Mage/Core/Helper/String.php | 30 +++++++++++++++++------ 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/app/code/core/Mage/Core/Helper/String.php b/app/code/core/Mage/Core/Helper/String.php index 80804850d94..de0b038e6d7 100644 --- a/app/code/core/Mage/Core/Helper/String.php +++ b/app/code/core/Mage/Core/Helper/String.php @@ -44,7 +44,7 @@ class Mage_Core_Helper_String extends Mage_Core_Helper_Abstract public function truncate($string, $length = 80, $etc = '...', &$remainder = '', $breakWords = true) { $remainder = ''; - if ($length == 0) { + if (is_null($string) || $length == 0) { return ''; } @@ -75,7 +75,7 @@ public function truncate($string, $length = 80, $etc = '...', &$remainder = '', */ public function strlen($string) { - return iconv_strlen($string, self::ICONV_CHARSET); + return is_null($string) ? 0 : iconv_strlen($string, self::ICONV_CHARSET); } /** @@ -88,6 +88,9 @@ public function strlen($string) */ public function substr($string, $offset, $length = null) { + if (is_null($string)) { + return ''; + } $string = $this->cleanString($string); if (is_null($length)) { $length = $this->strlen($string) - $offset; @@ -246,6 +249,9 @@ public function str_split($str, $length = 1, $keepWords = false, $trim = false, */ public function splitWords($str, $uniqueOnly = false, $maxWordLength = 0, $wordSeparatorRegexp = '\s') { + if (is_null($str)) { + return []; + } $result = []; $split = preg_split('#' . $wordSeparatorRegexp . '#siu', $str, -1, PREG_SPLIT_NO_EMPTY); foreach ($split as $word) { @@ -269,8 +275,12 @@ public function splitWords($str, $uniqueOnly = false, $maxWordLength = 0, $wordS */ public function cleanString($string) { - return '"libiconv"' == ICONV_IMPL ? - iconv(self::ICONV_CHARSET, self::ICONV_CHARSET . '//IGNORE', $string) : $string; + if (is_null($string)) { + return ''; + } + return '"libiconv"' == ICONV_IMPL + ? iconv(self::ICONV_CHARSET, self::ICONV_CHARSET . '//IGNORE', $string) + : $string; } /** @@ -279,11 +289,11 @@ public function cleanString($string) * @param string $haystack * @param string $needle * @param int $offset - * @return int + * @return int|false */ - public function strpos($haystack, $needle, $offset = null) + public function strpos($haystack, $needle, $offset = 0) { - return iconv_strpos($haystack, $needle, $offset, self::ICONV_CHARSET); + return iconv_strpos((string) $haystack, (string) $needle, $offset, self::ICONV_CHARSET); } /** @@ -315,6 +325,9 @@ public function ksortMultibyte(array &$sort) */ public function parseQueryStr($str) { + if (is_null($str)) { + return []; + } $argSeparator = '&'; $result = []; $partsQueryStr = explode($argSeparator, $str); @@ -510,6 +523,9 @@ public function uniOrd($c) */ public function unserialize($str) { + if (is_null($str)) { + return null; + } $reader = new Unserialize_Reader_ArrValue('data'); $prevChar = null; for ($i = 0; $i < strlen($str); $i++) {