Skip to content

Commit

Permalink
Merge branch 'main' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
fballiano committed Jun 21, 2023
2 parents cc78b50 + 9b8eded commit 0e0617d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 19 deletions.
22 changes: 11 additions & 11 deletions app/code/core/Mage/Catalog/Model/Resource/Category/Flat.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
30 changes: 23 additions & 7 deletions app/code/core/Mage/Core/Helper/String.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
}

Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}

/**
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -315,6 +325,9 @@ public function ksortMultibyte(array &$sort)
*/
public function parseQueryStr($str)
{
if (is_null($str)) {
return [];
}
$argSeparator = '&';
$result = [];
$partsQueryStr = explode($argSeparator, $str);
Expand Down Expand Up @@ -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++) {
Expand Down
6 changes: 5 additions & 1 deletion app/code/core/Mage/Sales/Model/Quote/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
}
Expand Down

0 comments on commit 0e0617d

Please sign in to comment.