@@ -296,11 +296,7 @@ protected function normalizeParameter(string $field, mixed $value): mixed
296
296
$ inversedObject = $ value ->withPersistMode (PersistMode::NO_PERSIST_BUT_SCHEDULE_FOR_INSERT )
297
297
->create ([$ inverseField => $ placeholder = (new \ReflectionClass (static ::class ()))->newInstanceWithoutConstructor ()]);
298
298
299
- // auto-refresh computes changeset and prevents the placeholder object to be cleanly
300
- // forgotten fom the persistence manager
301
- if ($ inversedObject instanceof Proxy) {
302
- $ inversedObject = $ inversedObject ->_real (withAutoRefresh: false );
303
- }
299
+ $ inversedObject = unproxy ($ inversedObject , withAutoRefresh: false );
304
300
305
301
$ this ->tempAfterInstantiate [] = static function (object $ object ) use ($ inversedObject , $ inverseField , $ pm , $ placeholder ) {
306
302
$ pm ->forget ($ placeholder );
@@ -311,7 +307,7 @@ protected function normalizeParameter(string $field, mixed $value): mixed
311
307
}
312
308
}
313
309
314
- return unproxy (parent ::normalizeParameter ($ field , $ value ));
310
+ return unproxy (parent ::normalizeParameter ($ field , $ value ), withAutoRefresh: false );
315
311
}
316
312
317
313
protected function normalizeCollection (string $ field , FactoryCollection $ collection ): array
@@ -330,7 +326,7 @@ protected function normalizeCollection(string $field, FactoryCollection $collect
330
326
331
327
$ inverseObjects = $ collection ->withPersistMode (PersistMode::NO_PERSIST_BUT_SCHEDULE_FOR_INSERT )->create ([$ inverseField => $ object ]);
332
328
333
- $ inverseObjects = unproxy ($ inverseObjects );
329
+ $ inverseObjects = unproxy ($ inverseObjects, withAutoRefresh: false );
334
330
335
331
// if the collection is indexed by a field, index the array
336
332
if ($ inverseRelationshipMetadata ->collectionIndexedBy ) {
@@ -366,9 +362,7 @@ protected function normalizeObject(object $object): object
366
362
return $ object ;
367
363
}
368
364
369
- if ($ object instanceof Proxy) {
370
- $ object = $ object ->_real (withAutoRefresh: false );
371
- }
365
+ $ object = unproxy ($ object , withAutoRefresh: false );
372
366
373
367
$ persistenceManager = $ configuration ->persistence ();
374
368
if (!$ persistenceManager ->hasPersistenceFor ($ object )) {
0 commit comments