Commit 17dc44a7 authored by Franco Fichtner's avatar Franco Fichtner

mvc: as previously seen PHP has trouble iterating over empty nodes

(cherry picked from commit 760af0b6)
(cherry picked from commit 41aef105)
parent b6af4c88
<?php <?php
/** /**
* Copyright (C) 2015 Deciso B.V. - J. Schellevis * Copyright (C) 2015 Deciso B.V. - J. Schellevis
*
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -24,10 +24,8 @@ ...@@ -24,10 +24,8 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*
*/ */
namespace OPNsense\Diagnostics\Api; namespace OPNsense\Diagnostics\Api;
use \OPNsense\Base\ApiControllerBase; use \OPNsense\Base\ApiControllerBase;
...@@ -599,7 +597,7 @@ class SystemhealthController extends ApiControllerBase ...@@ -599,7 +597,7 @@ class SystemhealthController extends ApiControllerBase
// collect interface names // collect interface names
$intfmap = array(); $intfmap = array();
$config = Config::getInstance()->object(); $config = Config::getInstance()->object();
if ($config->interfaces != null) { if ($config->interfaces->count() > 0) {
foreach ($config->interfaces->children() as $key => $node) { foreach ($config->interfaces->children() as $key => $node) {
$intfmap[(string)$key] = array("descr" => !empty((string)$node->descr) ? (string)$node->descr : $key); $intfmap[(string)$key] = array("descr" => !empty((string)$node->descr) ? (string)$node->descr : $key);
} }
......
...@@ -105,9 +105,12 @@ class MenuSystem ...@@ -105,9 +105,12 @@ class MenuSystem
} }
// add interfaces to "Interfaces" menu tab... kind of a hack, may need some improvement. // add interfaces to "Interfaces" menu tab... kind of a hack, may need some improvement.
$ifarr = array(); $ifarr = array();
foreach (Config::getInstance()->object()->interfaces->children() as $key => $node) { $config = Config::getInstance()->object();
if (empty($node->virtual)) { if ($config->interfaces->count() > 0) {
$ifarr[$key] = !empty($node->descr) ? (string)$node->descr : strtoupper($key); foreach ($config->interfaces->children() as $key => $node) {
if (empty($node->virtual)) {
$ifarr[$key] = !empty($node->descr) ? (string)$node->descr : strtoupper($key);
}
} }
} }
natcasesort($ifarr); natcasesort($ifarr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment