From e90f4ca020c7c1f1136037cfe36128b602d5296e Mon Sep 17 00:00:00 2001 From: Yasen Pramatarov Date: Fri, 1 Nov 2024 20:01:43 +0200 Subject: [PATCH] Fixes boolean fields in conf editing --- app/classes/config.php | 12 ++++++++++-- app/helpers/render.php | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/classes/config.php b/app/classes/config.php index d2ab502..850f119 100644 --- a/app/classes/config.php +++ b/app/classes/config.php @@ -17,8 +17,16 @@ class Config { // value is without quotes, because it could be true/false $pattern = "/(['\"]{$key}['\"]\s*=>\s*)([^,]+),/"; - // prepare the value and replace it - $replacementValue = var_export($newValue, true); + // prepare the value, treating booleans as 'true' or 'false' + if ($newValue === 1) { + $replacementValue = 'true'; + } elseif ($newValue === 0) { + $replacementValue = 'false'; + } else { + $replacementValue = var_export($newValue, true); + } + + // value replacing $config_contents = preg_replace($pattern, "$1{$replacementValue},", $config_contents); } diff --git a/app/helpers/render.php b/app/helpers/render.php index 335754b..a909fc6 100644 --- a/app/helpers/render.php +++ b/app/helpers/render.php @@ -57,6 +57,7 @@ function editConfig($configPart, $indent, $platform=false, $parent='') { ?>
+ />