Skip to content

Commit

Permalink
Don't use customvar values from customvar table other than for empt…
Browse files Browse the repository at this point in the history
…y `array` & `dictionary`
  • Loading branch information
yhabteab authored and nilmerg committed Oct 13, 2023
1 parent 701797e commit 0f380c8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion library/Icingadb/Model/CustomvarFlat.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};

Expand Down
2 changes: 1 addition & 1 deletion test/php/library/Icingadb/Model/CustomvarFlatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class CustomvarFlatTest extends TestCase
"example.0.org" => "xyz",
"ob" => [
"je" => [
"ct" => "tcejbo"
"ct" => "***"
]
],
"real_list" => [
Expand Down

0 comments on commit 0f380c8

Please sign in to comment.