Skip to content

Commit

Permalink
BranchController: ensure object type is set first
Browse files Browse the repository at this point in the history
fixes #2142
fixes #2634
  • Loading branch information
Thomas-Gelf committed Nov 3, 2022
1 parent 97ee1ea commit 3d1ad3d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 16 additions & 2 deletions application/controllers/BranchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions doc/82-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3d1ad3d

Please sign in to comment.