mirror of
https://github.com/opnsense/core.git
synced 2026-06-09 00:42:36 -04:00
Config - ditch isArraySequential() in favor of the new array_is_list() introduced in PHP 8.1. closes https://github.com/opnsense/core/pull/9424
This impacts $config usage in legacy code, a before and after comparison of the $config output shows no difference on a larger config file. As mentioned by @swhite2, the performance of the internal check is much better than the one we're replacing now. closes https://github.com/opnsense/core/pull/9424
This commit is contained in:
parent
b6b61f9e94
commit
7ee3b2c516
1 changed files with 2 additions and 12 deletions
|
|
@ -86,16 +86,6 @@ class Config extends Singleton
|
|||
return $this->statusIsValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if array is a sequential type.
|
||||
* @param &array $arrayData array structure to check
|
||||
* @return bool
|
||||
*/
|
||||
private function isArraySequential(&$arrayData)
|
||||
{
|
||||
return is_array($arrayData) && ctype_digit(implode('', array_keys($arrayData)));
|
||||
}
|
||||
|
||||
/**
|
||||
* serialize xml to array structure (backwards compatibility mode)
|
||||
* @param null|array $forceList force specific tags to be contained in a list.
|
||||
|
|
@ -128,7 +118,7 @@ class Config extends Singleton
|
|||
$old_content = $result[$xmlNodeName];
|
||||
// check if array content is associative, move items to new list
|
||||
// (handles first item of specific type)
|
||||
if (!$this->isArraySequential($old_content)) {
|
||||
if (!is_array($old_content) || !array_is_list($old_content)) {
|
||||
$result[$xmlNodeName] = array();
|
||||
$result[$xmlNodeName][] = $old_content;
|
||||
}
|
||||
|
|
@ -253,7 +243,7 @@ class Config extends Singleton
|
|||
} elseif (is_numeric($itemKey)) {
|
||||
// recurring tag (content), use parent tagname.
|
||||
$childNode = $node->addChild($parentTagName);
|
||||
} elseif ($this->isArraySequential($itemValue)) {
|
||||
} elseif (is_array($itemValue) && array_is_list($itemValue)) {
|
||||
// recurring tag, skip placeholder.
|
||||
$childNode = $node;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue