From 071b76999765a76879425eef2907d3a9cf61c015 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Mon, 18 Oct 2021 12:29:52 +0100 Subject: [PATCH] [CORE][Util][Common] Correct behaviour for absense of value --- src/Util/Common.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Util/Common.php b/src/Util/Common.php index f783f3da1c..ebf60b21d0 100644 --- a/src/Util/Common.php +++ b/src/Util/Common.php @@ -73,13 +73,22 @@ abstract class Common /** * Access sysadmin's configuration preferences for GNU social + * Returns value if exists, null if not set */ public static function config(string $section, ?string $setting = null) { - if ($setting !== null) { - return self::$config[$section][$setting]; + if (!array_key_exists($section, self::$config)) { + return null; } else { - return self::$config[$section] ?? []; + if ($setting !== null) { + if (array_key_exists($setting, self::$config[$section])) { + return self::$config[$section][$setting]; + } else { + return null; + } + } else { + return self::$config[$section]; + } } }