Skip to content

Commit

Permalink
Fixes core and lib issues for PHP 8.0 compatibility (#1391)
Browse files Browse the repository at this point in the history
* Fixes core and lib issues for PHP 8.0 compatibility

* Zend_Xml_Security: PHP8 fixes for version_compare
  • Loading branch information
lamskoy authored Apr 17, 2021
1 parent d44a8dd commit feebf55
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected function _buildMenuArray(Varien_Simplexml_Element $parent=null, $path=

uasort($parentArr, array($this, '_sortMenu'));

while (list($key, $value) = each($parentArr)) {
foreach ($parentArr as $key => $value) {
$last = $key;
}
if (isset($last)) {
Expand Down
14 changes: 7 additions & 7 deletions app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,10 @@ public function getOrderOptions($product = null)
{
$options = parent::getOrderOptions($product);
$options['attributes_info'] = $this->getSelectedAttributesInfo($product);
/** @var Mage_Sales_Model_Quote_Item_Option $simpleOption */
/** @var Mage_Sales_Model_Quote_Item_Option|Mage_Catalog_Model_Product_Configuration_Item_Option $simpleOption */
if ($simpleOption = $this->getProduct($product)->getCustomOption('simple_product')) {
$options['simple_name'] = $simpleOption->getProduct($product)->getName();
$options['simple_sku'] = $simpleOption->getProduct($product)->getSku();
$options['simple_name'] = $simpleOption->getProduct()->getName();
$options['simple_sku'] = $simpleOption->getProduct()->getSku();
}

$options['product_calculations'] = self::CALCULATE_PARENT;
Expand Down Expand Up @@ -784,8 +784,8 @@ public function getWeight($product = null)
if ($this->getProduct($product)->hasCustomOptions() &&
($simpleProductOption = $this->getProduct($product)->getCustomOption('simple_product'))
) {
/** @var Mage_Sales_Model_Quote_Item_Option $simpleProductOption */
$simpleProduct = $simpleProductOption->getProduct($product);
/** @var Mage_Sales_Model_Quote_Item_Option|Mage_Catalog_Model_Product_Configuration_Item_Option $simpleProductOption */
$simpleProduct = $simpleProductOption->getProduct();
if ($simpleProduct) {
return $simpleProduct->getWeight();
}
Expand Down Expand Up @@ -837,10 +837,10 @@ public function getSku($product = null)
/** @var Mage_Sales_Model_Quote_Item_Option $simpleOption */
$simpleOption = $this->getProduct($product)->getCustomOption('simple_product');
if ($simpleOption) {
$optionProduct = $simpleOption->getProduct($product);
$optionProduct = $simpleOption->getProduct();
$simpleSku = null;
if ($optionProduct) {
$simpleSku = $simpleOption->getProduct($product)->getSku();
$simpleSku = $simpleOption->getProduct()->getSku();
}
$sku = parent::getOptionSku($product, $simpleSku);
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/Mage/Cache/Backend/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function __construct(array $options = array())
}

// Don't use parent constructor
while (list($name, $value) = each($options)) {
foreach ($options as $name => $value) {
$this->setOption($name, $value);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Zend/Config/Yaml.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ protected static function _decodeYaml($currentIndent, &$lines)
{
$config = array();
$inIndent = false;
while (list($n, $line) = each($lines)) {
foreach($lines as $n => $line) {
$lineno = $n + 1;

$line = rtrim(preg_replace("/#.*$/", "", $line));
Expand Down
2 changes: 1 addition & 1 deletion lib/Zend/Feed/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function __get($var)
if ($length == 1) {
return new Zend_Feed_Element($nodes[0]);
} elseif ($length > 1) {
return array_map(create_function('$e', 'return new Zend_Feed_Element($e);'), $nodes);
return array_map(function($e) { return new Zend_Feed_Element($e); }, $nodes);
} else {
// When creating anonymous nodes for __set chaining, don't
// call appendChild() on them. Instead we pass the current
Expand Down
2 changes: 1 addition & 1 deletion lib/Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static function getAllCapabilities(TeraWurfl $wurflObj)
if (!is_array($group)) {
continue;
}
while (list ($key, $value) = each($group)) {
foreach($group as $key => $value) {
if (is_bool($value)) {
// to have the same type than the official WURFL API
$features[$key] = ($value ? 'true' : 'false');
Expand Down
6 changes: 3 additions & 3 deletions lib/Zend/Xml/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ public static function scanFile($file, DOMDocument $dom = null)
public static function isPhpFpm()
{
$isVulnerableVersion = (
version_compare(PHP_VERSION, '5.5.22', 'lt')
version_compare(PHP_VERSION, '5.5.22', '<')
|| (
version_compare(PHP_VERSION, '5.6', 'gte')
&& version_compare(PHP_VERSION, '5.6.6', 'lt')
version_compare(PHP_VERSION, '5.6', '>=')
&& version_compare(PHP_VERSION, '5.6.6', '<')
)
);

Expand Down
6 changes: 4 additions & 2 deletions lib/Zend/XmlRpc/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,13 +486,15 @@ protected static function _createSimpleXMLElement(&$xml)
*/
protected static function _extractTypeAndValue(SimpleXMLElement $xml, &$type, &$value)
{
list($type, $value) = each($xml);
$value = reset($xml);
$type = key($xml);

if (!$type and $value === null) {
$namespaces = array('ex' => 'http://ws.apache.org/xmlrpc/namespaces/extensions');
foreach ($namespaces as $namespaceName => $namespaceUri) {
$namespaceXml = $xml->children($namespaceUri);
list($type, $value) = each($namespaceXml);
$value = reset($namespaceXml);
$type = key($namespaceXml);
if ($type !== null) {
$type = $namespaceName . ':' . $type;
break;
Expand Down

0 comments on commit feebf55

Please sign in to comment.