@@ -131,16 +131,29 @@ public function onFlush(EventArgs $eventArgs): void
131
131
public function postFlush (): void
132
132
{
133
133
try {
134
- foreach ($ this ->createdObjects as $ object ) {
135
- $ this ->publishUpdate ($ object , $ this ->createdObjects [$ object ], 'create ' );
134
+ $ creatingObjects = clone $ this ->createdObjects ;
135
+ foreach ($ creatingObjects as $ object ) {
136
+ if ($ this ->createdObjects ->contains ($ object )) {
137
+ $ this ->createdObjects ->detach ($ object );
138
+ }
139
+ $ this ->publishUpdate ($ object , $ creatingObjects [$ object ], 'create ' );
136
140
}
137
141
138
- foreach ($ this ->updatedObjects as $ object ) {
139
- $ this ->publishUpdate ($ object , $ this ->updatedObjects [$ object ], 'update ' );
142
+ $ updatingObjects = clone $ this ->updatedObjects ;
143
+ foreach ($ updatingObjects as $ object ) {
144
+ if ($ this ->updatedObjects ->contains ($ object )) {
145
+ $ this ->updatedObjects ->detach ($ object );
146
+ }
147
+ $ this ->publishUpdate ($ object , $ updatingObjects [$ object ], 'update ' );
140
148
}
141
149
142
- foreach ($ this ->deletedObjects as $ object ) {
143
- $ this ->publishUpdate ($ object , $ this ->deletedObjects [$ object ], 'delete ' );
150
+ $ deletingObjects = clone $ this ->deletedObjects ;
151
+ foreach ($ deletingObjects as $ object ) {
152
+ $ options = $ this ->deletedObjects [$ object ];
153
+ if ($ this ->deletedObjects ->contains ($ object )) {
154
+ $ this ->deletedObjects ->detach ($ object );
155
+ }
156
+ $ this ->publishUpdate ($ object , $ deletingObjects [$ object ], 'delete ' );
144
157
}
145
158
} finally {
146
159
$ this ->reset ();
@@ -237,7 +250,6 @@ private function publishUpdate(object $object, array $options, string $type): vo
237
250
}
238
251
239
252
$ updates = array_merge ([$ this ->buildUpdate ($ iri , $ data , $ options )], $ this ->getGraphQlSubscriptionUpdates ($ object , $ options , $ type ));
240
-
241
253
foreach ($ updates as $ update ) {
242
254
if ($ options ['enable_async_update ' ] && $ this ->messageBus ) {
243
255
$ this ->dispatch ($ update );
0 commit comments