File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -302,8 +302,8 @@ public function executeInserts()
302302 $ this ->assignDefaultVersionAndUpsertableValues ($ entity , $ id );
303303 }
304304
305- // Unset this queued insert, so that the prepareUpdateData() method knows right away
306- // (for the next entity already) that the current entity has been written to the database
305+ // Unset this queued insert, so that the prepareUpdateData() method (called via prepareInsertData() method)
306+ // knows right away (for the next entity already) that the current entity has been written to the database
307307 // and no extra updates need to be scheduled to refer to it.
308308 //
309309 // In \Doctrine\ORM\UnitOfWork::executeInserts(), the UoW already removed entities
Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ public function executeInserts()
149149 // Execute all inserts. For each entity:
150150 // 1) Insert on root table
151151 // 2) Insert on sub tables
152- foreach ($ this ->queuedInserts as $ entity ) {
152+ foreach ($ this ->queuedInserts as $ key => $ entity ) {
153153 $ insertData = $ this ->prepareInsertData ($ entity );
154154
155155 // Execute insert on root table
@@ -194,9 +194,16 @@ public function executeInserts()
194194 if ($ this ->class ->requiresFetchAfterChange ) {
195195 $ this ->assignDefaultVersionAndUpsertableValues ($ entity , $ id );
196196 }
197- }
198197
199- $ this ->queuedInserts = [];
198+ // Unset this queued insert, so that the prepareUpdateData() method (called via prepareInsertData() method)
199+ // knows right away (for the next entity already) that the current entity has been written to the database
200+ // and no extra updates need to be scheduled to refer to it.
201+ //
202+ // In \Doctrine\ORM\UnitOfWork::executeInserts(), the UoW already removed entities
203+ // from its own list (\Doctrine\ORM\UnitOfWork::$entityInsertions) right after they
204+ // were given to our addInsert() method.
205+ unset($ this ->queuedInserts [$ key ]);
206+ }
200207 }
201208
202209 /**
You can’t perform that action at this time.
0 commit comments