From 02b9e20ce3b521422661965fcbfcb437ed3652e3 Mon Sep 17 00:00:00 2001 From: billz Date: Sun, 2 Mar 2025 00:24:57 -0800 Subject: [PATCH] Use ?? to avoid undefined key warnings --- includes/functions.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 7d24a4f3..f41e1ecb 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -177,15 +177,17 @@ function getDefaultNetOpts($svc,$key) * @param string $key * @return object $json */ -function getProviderValue($id,$key) +function getProviderValue($id, $key) { $obj = json_decode(file_get_contents(RASPI_CONFIG_PROVIDERS), true); - if ($obj === null) { + if (!isset($obj['providers']) || !is_array($obj['providers'])) { return false; - } else { - $id--; - return $obj['providers'][$id][$key]; } + $id--; + if (!isset($obj['providers'][$id]) || !is_array($obj['providers'][$id])) { + return false; + } + return $obj['providers'][$id][$key] ?? false; } /* Functions to write ini files */