Skip to content

Commit feebf55

Browse files
authored
Fixes core and lib issues for PHP 8.0 compatibility (#1391)
* Fixes core and lib issues for PHP 8.0 compatibility * Zend_Xml_Security: PHP8 fixes for version_compare
1 parent d44a8dd commit feebf55

File tree

8 files changed

+19
-17
lines changed

8 files changed

+19
-17
lines changed

app/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ protected function _buildMenuArray(Varien_Simplexml_Element $parent=null, $path=
124124

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

127-
while (list($key, $value) = each($parentArr)) {
127+
foreach ($parentArr as $key => $value) {
128128
$last = $key;
129129
}
130130
if (isset($last)) {

app/code/core/Mage/Catalog/Model/Product/Type/Configurable.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -718,10 +718,10 @@ public function getOrderOptions($product = null)
718718
{
719719
$options = parent::getOrderOptions($product);
720720
$options['attributes_info'] = $this->getSelectedAttributesInfo($product);
721-
/** @var Mage_Sales_Model_Quote_Item_Option $simpleOption */
721+
/** @var Mage_Sales_Model_Quote_Item_Option|Mage_Catalog_Model_Product_Configuration_Item_Option $simpleOption */
722722
if ($simpleOption = $this->getProduct($product)->getCustomOption('simple_product')) {
723-
$options['simple_name'] = $simpleOption->getProduct($product)->getName();
724-
$options['simple_sku'] = $simpleOption->getProduct($product)->getSku();
723+
$options['simple_name'] = $simpleOption->getProduct()->getName();
724+
$options['simple_sku'] = $simpleOption->getProduct()->getSku();
725725
}
726726

727727
$options['product_calculations'] = self::CALCULATE_PARENT;
@@ -784,8 +784,8 @@ public function getWeight($product = null)
784784
if ($this->getProduct($product)->hasCustomOptions() &&
785785
($simpleProductOption = $this->getProduct($product)->getCustomOption('simple_product'))
786786
) {
787-
/** @var Mage_Sales_Model_Quote_Item_Option $simpleProductOption */
788-
$simpleProduct = $simpleProductOption->getProduct($product);
787+
/** @var Mage_Sales_Model_Quote_Item_Option|Mage_Catalog_Model_Product_Configuration_Item_Option $simpleProductOption */
788+
$simpleProduct = $simpleProductOption->getProduct();
789789
if ($simpleProduct) {
790790
return $simpleProduct->getWeight();
791791
}
@@ -837,10 +837,10 @@ public function getSku($product = null)
837837
/** @var Mage_Sales_Model_Quote_Item_Option $simpleOption */
838838
$simpleOption = $this->getProduct($product)->getCustomOption('simple_product');
839839
if ($simpleOption) {
840-
$optionProduct = $simpleOption->getProduct($product);
840+
$optionProduct = $simpleOption->getProduct();
841841
$simpleSku = null;
842842
if ($optionProduct) {
843-
$simpleSku = $simpleOption->getProduct($product)->getSku();
843+
$simpleSku = $simpleOption->getProduct()->getSku();
844844
}
845845
$sku = parent::getOptionSku($product, $simpleSku);
846846
} else {

lib/Mage/Cache/Backend/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function __construct(array $options = array())
104104
}
105105

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

lib/Zend/Config/Yaml.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ protected static function _decodeYaml($currentIndent, &$lines)
289289
{
290290
$config = array();
291291
$inIndent = false;
292-
while (list($n, $line) = each($lines)) {
292+
foreach($lines as $n => $line) {
293293
$lineno = $n + 1;
294294

295295
$line = rtrim(preg_replace("/#.*$/", "", $line));

lib/Zend/Feed/Element.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function __get($var)
193193
if ($length == 1) {
194194
return new Zend_Feed_Element($nodes[0]);
195195
} elseif ($length > 1) {
196-
return array_map(create_function('$e', 'return new Zend_Feed_Element($e);'), $nodes);
196+
return array_map(function($e) { return new Zend_Feed_Element($e); }, $nodes);
197197
} else {
198198
// When creating anonymous nodes for __set chaining, don't
199199
// call appendChild() on them. Instead we pass the current

lib/Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static function getAllCapabilities(TeraWurfl $wurflObj)
8888
if (!is_array($group)) {
8989
continue;
9090
}
91-
while (list ($key, $value) = each($group)) {
91+
foreach($group as $key => $value) {
9292
if (is_bool($value)) {
9393
// to have the same type than the official WURFL API
9494
$features[$key] = ($value ? 'true' : 'false');

lib/Zend/Xml/Security.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ public static function scanFile($file, DOMDocument $dom = null)
167167
public static function isPhpFpm()
168168
{
169169
$isVulnerableVersion = (
170-
version_compare(PHP_VERSION, '5.5.22', 'lt')
170+
version_compare(PHP_VERSION, '5.5.22', '<')
171171
|| (
172-
version_compare(PHP_VERSION, '5.6', 'gte')
173-
&& version_compare(PHP_VERSION, '5.6.6', 'lt')
172+
version_compare(PHP_VERSION, '5.6', '>=')
173+
&& version_compare(PHP_VERSION, '5.6.6', '<')
174174
)
175175
);
176176

lib/Zend/XmlRpc/Value.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,13 +486,15 @@ protected static function _createSimpleXMLElement(&$xml)
486486
*/
487487
protected static function _extractTypeAndValue(SimpleXMLElement $xml, &$type, &$value)
488488
{
489-
list($type, $value) = each($xml);
489+
$value = reset($xml);
490+
$type = key($xml);
490491

491492
if (!$type and $value === null) {
492493
$namespaces = array('ex' => 'http://ws.apache.org/xmlrpc/namespaces/extensions');
493494
foreach ($namespaces as $namespaceName => $namespaceUri) {
494495
$namespaceXml = $xml->children($namespaceUri);
495-
list($type, $value) = each($namespaceXml);
496+
$value = reset($namespaceXml);
497+
$type = key($namespaceXml);
496498
if ($type !== null) {
497499
$type = $namespaceName . ':' . $type;
498500
break;

0 commit comments

Comments
 (0)