From 861fb8e091dee1397a7e3f5edd01784f6247759a Mon Sep 17 00:00:00 2001 From: raviks789 Date: Fri, 26 Jul 2024 14:48:48 +0200 Subject: [PATCH] Fix sync rule preview in case of boolean properties --- data2.json | 19 +++++++++++++++++++ library/Director/Db/Branch/BranchedObject.php | 12 ++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 data2.json diff --git a/data2.json b/data2.json new file mode 100644 index 000000000..cae3d783c --- /dev/null +++ b/data2.json @@ -0,0 +1,19 @@ +{ + "apply_to": "service", + "assign_filter": "host.name=%22h1%22", + "imports": [ + "nt1" + ], + "notification_interval": 1, + "object_name": "n2", + "object_type": "apply", + "states": [ + "Warning" + ], + "types": [ + "Problem" + ], + "users": [ + "u1" + ] +} diff --git a/library/Director/Db/Branch/BranchedObject.php b/library/Director/Db/Branch/BranchedObject.php index 0f276c211..0a930d673 100644 --- a/library/Director/Db/Branch/BranchedObject.php +++ b/library/Director/Db/Branch/BranchedObject.php @@ -3,10 +3,12 @@ namespace Icinga\Module\Director\Db\Branch; use Icinga\Exception\NotFoundError; +use Icinga\Module\Director\Data\Db\DbDataFormatter; use Icinga\Module\Director\Data\Db\DbObject; use Icinga\Module\Director\Data\Db\DbObjectTypeRegistry; use Icinga\Module\Director\Data\Json; use Icinga\Module\Director\Db; +use Icinga\Module\Director\Objects\IcingaObject; use Ramsey\Uuid\UuidInterface; use stdClass; @@ -198,7 +200,17 @@ public function applyActivity(BranchActivity $activity, Db $connection) } } + $dummyObject = IcingaObject::createByType( + $this->objectTable, + [], + $connection + ); + foreach ($activity->getModifiedProperties()->jsonSerialize() as $key => $value) { + if ($dummyObject->propertyIsBoolean($key)) { + $value = DbDataFormatter::normalizeBoolean($value); + } + $this->changes[$key] = $value; }