Skip to content

Commit c7b3909

Browse files
committed
Add test to avoid warnings when missing interface
- See issue #148.
1 parent 3c67774 commit c7b3909

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

classes/local/utils.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,11 @@ public static function get_ethernet_interface_name() {
185185
$iter = new \RecursiveIteratorIterator($iter, \RecursiveIteratorIterator::CHILD_FIRST);
186186
$iter = new \RegexIterator($iter, '|^.*/device$|i', \RecursiveRegexIterator::GET_MATCH);
187187
$iter->setMaxDepth(2);
188-
$matches = array_values(preg_grep('#^.*/(eth|en).*$#i', array_keys(iterator_to_array($iter))))[0];
189-
return explode('/', $matches)[4];
188+
if ( $matches = array_values(preg_grep('#^.*/(eth|en).*$#i', array_keys(iterator_to_array($iter)))) ) {
189+
return explode('/', $matches[0])[4];
190+
} else {
191+
return false;
192+
}
190193
} else {
191194
return false;
192195
}

0 commit comments

Comments
 (0)