From 2a37db1115a8a3086d14c9c0ae23ba5e8a202724 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 3 Nov 2022 07:25:39 +0100 Subject: [PATCH] BranchController: ensure object type is set first fixes #2142 fixes #2634 --- application/controllers/BranchController.php | 18 ++++++++++++++++-- doc/82-Changelog.md | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/application/controllers/BranchController.php b/application/controllers/BranchController.php index cdbab3a80..3b36e83b5 100644 --- a/application/controllers/BranchController.php +++ b/application/controllers/BranchController.php @@ -72,7 +72,8 @@ protected function leftFromActivity(BranchActivity $activity) return null; } $object = DbObjectTypeRegistry::newObject($activity->getObjectTable(), [], $this->db()); - foreach ($activity->getFormerProperties()->jsonSerialize() as $key => $value) { + $properties = $this->objectTypeFirst($activity->getFormerProperties()->jsonSerialize()); + foreach ($properties as $key => $value) { $object->set($key, $value); } @@ -90,13 +91,26 @@ protected function rightFromActivity(BranchActivity $activity) $object->set($key, $value); } } - foreach ($activity->getModifiedProperties()->jsonSerialize() as $key => $value) { + $properties = $this->objectTypeFirst($activity->getModifiedProperties()->jsonSerialize()); + foreach ($properties as $key => $value) { $object->set($key, $value); } return $object; } + protected function objectTypeFirst($properties) + { + $properties = (array) $properties; + if (isset($properties['object_type'])) { + $type = $properties['object_type']; + unset($properties['object_type']); + $properties = ['object_type' => $type] + $properties; + } + + return $properties; + } + protected function showActivity(BranchActivity $activity) { $left = $this->leftFromActivity($activity); diff --git a/doc/82-Changelog.md b/doc/82-Changelog.md index 100b33421..78b3d8bce 100644 --- a/doc/82-Changelog.md +++ b/doc/82-Changelog.md @@ -18,6 +18,7 @@ v1.10.2 (unreleased) ### Import and Sync * FIX: triggering Sync manually produced an error on PostgreSQL (#2636) * FIX: purge stopped working for objects with uppercase characters (#2627) +* FIX: Notification Apply rule is now possible (wasn't since v1.8) (#2142, #2634) ### Configuration Baskets * FEATURE: more details shown in error messages related to invalid characters (#2646)