@@ -216,15 +216,23 @@ public function applyEntry(AbstractDBElement $element, TimeTravelInterface $logE
216
216
$ old_data = $ logEntry ->getOldData ();
217
217
218
218
foreach ($ old_data as $ field => $ data ) {
219
- if ($ metadata ->hasField ($ field )) {
219
+
220
+ //We use the fieldMappings property directly instead of the hasField method, as we do not want to match the embedded field itself
221
+ //The sub fields are handled in the setField method
222
+ if (isset ($ metadata ->fieldMappings [$ field ])) {
220
223
//We need to convert the string to a BigDecimal first
221
224
if (!$ data instanceof BigDecimal && ('big_decimal ' === $ metadata ->getFieldMapping ($ field )->type )) {
222
225
$ data = BigDecimal::of ($ data );
223
226
}
224
227
225
228
if (!$ data instanceof \DateTimeInterface
226
229
&& (in_array ($ metadata ->getFieldMapping ($ field )->type ,
227
- [Types::DATETIME_IMMUTABLE , Types::DATETIME_IMMUTABLE , Types::DATE_MUTABLE , Types::DATETIME_IMMUTABLE ], true ))) {
230
+ [
231
+ Types::DATETIME_IMMUTABLE ,
232
+ Types::DATETIME_IMMUTABLE ,
233
+ Types::DATE_MUTABLE ,
234
+ Types::DATETIME_IMMUTABLE
235
+ ], true ))) {
228
236
$ data = $ this ->dateTimeDecode ($ data , $ metadata ->getFieldMapping ($ field )->type );
229
237
}
230
238
@@ -267,9 +275,11 @@ protected function setField(AbstractDBElement $element, string $field, mixed $ne
267
275
268
276
$ embeddedReflection = new ReflectionClass ($ embeddedClass ::class);
269
277
$ property = $ embeddedReflection ->getProperty ($ embedded_field );
278
+ $ target_element = $ embeddedClass ;
270
279
} else {
271
280
$ reflection = new ReflectionClass ($ element ::class);
272
281
$ property = $ reflection ->getProperty ($ field );
282
+ $ target_element = $ element ;
273
283
}
274
284
275
285
//Check if the property is an BackedEnum, then convert the int or float value to an enum instance
@@ -281,6 +291,6 @@ protected function setField(AbstractDBElement $element, string $field, mixed $ne
281
291
$ new_value = $ enum_class ::from ($ new_value );
282
292
}
283
293
284
- $ property ->setValue ($ element , $ new_value );
294
+ $ property ->setValue ($ target_element , $ new_value );
285
295
}
286
296
}
0 commit comments