Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes core and lib issues for PHP 8.0 compatibility #1391

Merged
merged 4 commits into from
Apr 17, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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) {
sreichel marked this conversation as resolved.
Show resolved Hide resolved
$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) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add space after 'foreach' to meet PSR-4 standards:
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) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add space after 'foreach' to meet PSR-4 standards:
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically this is a logic change, as each() returns the current, and reset() the first.
Also each() moves the internal coursor.
But from the usage here it seems to not matter, and also makes the result more predictable, so Iam ok with leaving it as it is.

$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
4 changes: 3 additions & 1 deletion lib/phpseclib/Crypt/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,9 @@ function __construct($mode = self::MODE_CBC)

// Determining whether inline crypting can be used by the cipher
if ($this->use_inline_crypt !== false) {
$this->use_inline_crypt = version_compare(PHP_VERSION, '5.3.0') >= 0 || function_exists('create_function');
$this->use_inline_crypt =
(version_compare(PHP_VERSION, '5.3.0') >= 0 && version_compare(PHP_VERSION, '8.0.0') < 0)
|| function_exists('create_function');
}
}

Expand Down