BranchController: ensure object type is set first

fixes #2142
fixes #2634
This commit is contained in:
Thomas Gelf 2022-11-03 07:25:39 +01:00
parent ab952f89b0
commit 2a37db1115
2 changed files with 17 additions and 2 deletions

View File

@ -72,7 +72,8 @@ class BranchController extends ActionController
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 @@ class BranchController extends ActionController
$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);

View File

@ -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)