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
/**
* Copyright (C) 2015 Deciso B.V. - J. Schellevis
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -24,10 +24,8 @@
* 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
* POSSIBILITY OF SUCH DAMAGE.
*
*/
namespace OPNsense\Diagnostics\Api;
use \OPNsense\Base\ApiControllerBase;
......@@ -599,7 +597,7 @@ class SystemhealthController extends ApiControllerBase
// collect interface names
$intfmap = array();
$config = Config::getInstance()->object();
if ($config->interfaces != null) {
if ($config->interfaces->count() > 0) {
foreach ($config->interfaces->children() as $key => $node) {
$intfmap[(string)$key] = array("descr" => !empty((string)$node->descr) ? (string)$node->descr : $key);
}
......
......@@ -105,9 +105,12 @@ class MenuSystem
}
// add interfaces to "Interfaces" menu tab... kind of a hack, may need some improvement.
$ifarr = array();
foreach (Config::getInstance()->object()->interfaces->children() as $key => $node) {
if (empty($node->virtual)) {
$ifarr[$key] = !empty($node->descr) ? (string)$node->descr : strtoupper($key);
$config = Config::getInstance()->object();
if ($config->interfaces->count() > 0) {
foreach ($config->interfaces->children() as $key => $node) {
if (empty($node->virtual)) {
$ifarr[$key] = !empty($node->descr) ? (string)$node->descr : strtoupper($key);
}
}
}
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