From 0f380c8411b2c7ff774c80bfdc4b7281290668e9 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Wed, 11 Oct 2023 13:53:34 +0200 Subject: [PATCH] Don't use customvar values from `customvar` table other than for empty `array` & `dictionary` --- library/Icingadb/Model/CustomvarFlat.php | 2 +- test/php/library/Icingadb/Model/CustomvarFlatTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Icingadb/Model/CustomvarFlat.php b/library/Icingadb/Model/CustomvarFlat.php index 97b0254fd..99d8acae1 100644 --- a/library/Icingadb/Model/CustomvarFlat.php +++ b/library/Icingadb/Model/CustomvarFlat.php @@ -126,7 +126,7 @@ public function unFlattenVars(Traversable $flattenedVars): array // Since empty custom vars of type dictionaries and arrays have null values in customvar_flat table, // we won't be able to render them as such. Therefore, we have to use the value of the `customvar` // table if it's not null, otherwise the current value, which is a "null" string. - $data[$step] = $source[$step] ?? $value; + $data[$step] = $value === null && ($source[$step] ?? null) === [] ? $source[$step] : $value; } }; diff --git a/test/php/library/Icingadb/Model/CustomvarFlatTest.php b/test/php/library/Icingadb/Model/CustomvarFlatTest.php index b75733c18..a69f57800 100644 --- a/test/php/library/Icingadb/Model/CustomvarFlatTest.php +++ b/test/php/library/Icingadb/Model/CustomvarFlatTest.php @@ -70,7 +70,7 @@ class CustomvarFlatTest extends TestCase "example.0.org" => "xyz", "ob" => [ "je" => [ - "ct" => "tcejbo" + "ct" => "***" ] ], "real_list" => [