Skip to content

Commit 9ada9f9

Browse files
authored
Merge pull request #1777 from RaspAP/maint/php-warnings
Fix PHP warning in getProviderValue()
2 parents 313e2eb + 02b9e20 commit 9ada9f9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

includes/functions.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,17 @@ function getDefaultNetOpts($svc,$key)
177177
* @param string $key
178178
* @return object $json
179179
*/
180-
function getProviderValue($id,$key)
180+
function getProviderValue($id, $key)
181181
{
182182
$obj = json_decode(file_get_contents(RASPI_CONFIG_PROVIDERS), true);
183-
if ($obj === null) {
183+
if (!isset($obj['providers']) || !is_array($obj['providers'])) {
184+
return false;
185+
}
186+
$id--;
187+
if (!isset($obj['providers'][$id]) || !is_array($obj['providers'][$id])) {
184188
return false;
185-
} else {
186-
$id--;
187-
return $obj['providers'][$id][$key];
188189
}
190+
return $obj['providers'][$id][$key] ?? false;
189191
}
190192

191193
/* Functions to write ini files */

0 commit comments

Comments
 (0)