From 7ee3b2c516590bae918532ba406960ef2bf426db Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Wed, 19 Nov 2025 15:50:00 +0100 Subject: [PATCH] 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 --- .../mvc/app/library/OPNsense/Core/Config.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/opnsense/mvc/app/library/OPNsense/Core/Config.php b/src/opnsense/mvc/app/library/OPNsense/Core/Config.php index 037694c209..1e3dbf3d76 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Core/Config.php +++ b/src/opnsense/mvc/app/library/OPNsense/Core/Config.php @@ -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 {