Skip to content
Open
54 changes: 35 additions & 19 deletions app/code/core/Mage/Api2/Helper/Data.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

/**
Expand Down Expand Up @@ -53,25 +53,23 @@
*/
public function getAuthAdapters($enabledOnly = false)
{
$adapters = Mage::getConfig()->getNode(self::XML_PATH_AUTH_ADAPTERS);
$adapters = Mage::getConfig()?->getNode(self::XML_PATH_AUTH_ADAPTERS);

if (!$adapters) {
if (!$adapters instanceof Varien_Simplexml_Element) {
return [];
}

$adapters = $adapters->asArray();

if ($enabledOnly) {
foreach ($adapters as $adapter) {
if (empty($adapter['enabled'])) {
unset($adapters);
}
}
if (!is_array($adapters)) {
return [];
}

$adapters = (array) $adapters;
if ($enabledOnly) {
$adapters = array_filter($adapters, fn($adapter) => !empty($adapter['enabled']));
}

uasort($adapters, ['Mage_Api2_Helper_Data', '_compareOrder']);
uasort($adapters, self::_compareOrder(...));

return $adapters;
}
Expand All @@ -83,14 +81,22 @@
*/
public function getUserTypes()
{
$userModels = [];
$types = Mage::getConfig()->getNode(self::XML_PATH_USER_TYPES);
$types = Mage::getConfig()?->getNode(self::XML_PATH_USER_TYPES);

if (!$types instanceof Varien_Simplexml_Element) {
return [];
}

$types = $types->asArray();

if ($types) {
foreach ($types->asArray() as $type => $params) {
if (!empty($params['allowed'])) {
$userModels[$type] = $params['model'];
}
if (!is_array($types)) {
return [];
}

$userModels = [];
foreach ($types as $type => $params) {
if (!empty($params['allowed'])) {
$userModels[$type] = $params['model'];
}
}

Expand All @@ -104,7 +110,12 @@
*/
public function getRequestInterpreterAdapters()
{
return (array) Mage::app()->getConfig()->getNode(self::XML_PATH_API2_REQUEST_INTERPRETERS);
$node = Mage::app()->getConfig()->getNode(self::XML_PATH_API2_REQUEST_INTERPRETERS);
if (!$node instanceof Varien_Simplexml_Element) {
return [];
}

return (array) $node;
Comment thread
Hanmac marked this conversation as resolved.
Outdated
}

/**
Expand All @@ -114,7 +125,12 @@
*/
public function getResponseRenderAdapters()
{
return (array) Mage::app()->getConfig()->getNode(self::XML_PATH_API2_RESPONSE_RENDERS);
$node = Mage::app()->getConfig()->getNode(self::XML_PATH_API2_RESPONSE_RENDERS);
if (!$node instanceof Varien_Simplexml_Element) {
return [];
}

return (array) $node;
}

/**
Expand Down
13 changes: 12 additions & 1 deletion app/code/core/Mage/Payment/Helper/Data.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

/**
Expand Down Expand Up @@ -242,7 +242,18 @@
}

if ($asLabelValue && $withGroups) {
$groups = Mage::app()->getConfig()->getNode(self::XML_PATH_PAYMENT_GROUPS)->asCanonicalArray();
$groups = Mage::app()->getConfig()->getNode(self::XML_PATH_PAYMENT_GROUPS);

if ($groups instanceof Varien_Simplexml_Element) {
$groups = $groups->asCanonicalArray();

if (!is_array($groups)) {
$groups = [];
}
} else {
$groups = [];
}

foreach ($groups as $code => $title) {
$methods[$code] = $title; // for sorting, see below
}
Expand Down
32 changes: 13 additions & 19 deletions app/code/core/Mage/Payment/Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,19 @@ protected function _getMethod($code, $config, $store = null)
*/
public function getCcTypes()
{
$_types = Mage::getConfig()->getNode('global/payment/cc/types')->asArray();
$_types = Mage::getConfig()->getNode('global/payment/cc/types');

uasort($_types, ['Mage_Payment_Model_Config', 'compareCcTypes']);
if ($_types === false) {
Comment thread
Hanmac marked this conversation as resolved.
Outdated
return [];
}

$_types = $_types->asArray();

if (is_string($_types)) {
Comment thread
Hanmac marked this conversation as resolved.
Outdated
return [];
}

uasort($_types, self::compareCcTypes(...));

$types = [];
foreach ($_types as $data) {
Expand Down Expand Up @@ -155,22 +165,6 @@ public function getYears()
*/
public static function compareCcTypes($sortA, $sortB)
{
if (!isset($sortA['order'])) {
$sortA['order'] = 0;
}

if (!isset($sortB['order'])) {
$sortB['order'] = 0;
}

if ($sortA['order'] == $sortB['order']) {
return 0;
}

if ($sortA['order'] > $sortB['order']) {
return 1;
}

return -1;
return ($sortA['order'] ?? 0) <=> ($sortB['order'] ?? 0);
}
}
4 changes: 2 additions & 2 deletions lib/Varien/Data/Collection/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Varien_Data_Collection_Db extends Varien_Data_Collection
/**
* Fields map for correlation names & real selected fields
*
* @var null|array{fields: array<string, string>}
* @var null|array<string, array<string, string|Zend_Db_Expr>>
Comment thread
Hanmac marked this conversation as resolved.
*/
protected $_map = null;

Expand Down Expand Up @@ -899,7 +899,7 @@ public function addFilterToMap($filter, $alias, $group = 'fields')
{
if (is_null($this->_map)) {
$this->_map = [$group => []];
} elseif (is_null($this->_map[$group])) {
} elseif (!isset($this->_map[$group])) {
Comment thread
Hanmac marked this conversation as resolved.
Outdated
$this->_map[$group] = [];
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Varien/Image/Adapter/Gd2.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ public function save($destination = null, $newName = null)
{
if (isset($destination) && isset($newName)) {
$fileName = $destination . '/' . $newName;
} elseif (isset($destination) && !isset($newName)) {
} elseif (isset($destination)) {
$info = pathinfo($destination);
$fileName = $destination;
$destination = $info['dirname'];
} elseif (!isset($destination) && isset($newName)) {
} elseif (isset($newName)) {
$fileName = $this->_fileSrcPath . '/' . $newName;
} else {
$fileName = $this->_fileSrcPath . $this->_fileSrcName;
Expand Down
Loading