@@ -320,8 +320,18 @@ The `Model.afterSave` event is fired after an entity is saved.
320320The ` Model.afterSaveCommit ` event is fired after the transaction in which the
321321save operation is wrapped has been committed. It's also triggered for non atomic
322322saves where database operations are implicitly committed. The event is triggered
323- only for the primary table on which ` save() ` is directly called. The event is
324- not triggered if a transaction is started before calling save.
323+ only for the primary table on which ` save() ` is directly called.
324+
325+ When ` save() ` is called inside an outer transaction (e.g. one started with
326+ ` Connection::begin() ` ), the event is deferred until the outermost transaction
327+ commits. If the outer transaction is rolled back, the event is discarded. This
328+ ensures the event only fires after data has been persisted to the database.
329+
330+ ::: info Changed in version 5.4.0
331+ Previously, this event was not triggered if a transaction was started before
332+ calling ` save() ` . It is now deferred and fires after the outermost
333+ transaction commits.
334+ :::
325335
326336### beforeDelete
327337
@@ -342,10 +352,19 @@ The `Model.afterDelete` event is fired after an entity has been deleted.
342352` method ` Cake\\ ORM\\ Table::** afterDeleteCommit** (EventInterface $event, EntityInterface $entity, ArrayObject $options): void
343353
344354The ` Model.afterDeleteCommit ` event is fired after the transaction in which the
345- delete operation is wrapped has been is committed. It's also triggered for non
355+ delete operation is wrapped has been committed. It's also triggered for non
346356atomic deletes where database operations are implicitly committed. The event is
347357triggered only for the primary table on which ` delete() ` is directly called.
348- The event is not triggered if a transaction is started before calling delete.
358+
359+ When ` delete() ` is called inside an outer transaction, the event is deferred
360+ until the outermost transaction commits. If the outer transaction is rolled
361+ back, the event is discarded.
362+
363+ ::: info Changed in version 5.4.0
364+ Previously, this event was not triggered if a transaction was started before
365+ calling ` delete() ` . It is now deferred and fires after the outermost
366+ transaction commits.
367+ :::
349368
350369### Stopping Table Events
351370
0 commit comments