Feature: add a new event for many-to-many relationships#498
Feature: add a new event for many-to-many relationships#498andrestejerina97 wants to merge 1 commit intomainfrom
Conversation
ffb0da8 to
e142976
Compare
e5584c1 to
1613295
Compare
1613295 to
bd0d027
Compare
|
@martinquiroga-exo ready to review |
| ]; | ||
|
|
||
| $eventType = $isManyToMany | ||
| ? ($isDeletion ? IAuditStrategy::EVENT_COLLECTION_MANYTOMANY_DELETE : IAuditStrategy::EVENT_COLLECTION_MANYTOMANY_UPDATE) |
There was a problem hiding this comment.
Not sure about this concatenated ternary operators, perhaps I would like to see an exit early guard clause when the event is an EVENT_COLLECTION_UPDATE.
I defer to Casey on this one since is a design issue rather than an implementation one.
caseylocker
left a comment
There was a problem hiding this comment.
I'm going to defer to whatever Seb comes up with but this is what I'm seeing.
The auditCollection() method changed the calling convention for all collection updates not just ManyToMany. For non-ManyToMany collections, it now passes $owner (the entity) as the subject instead of $col (the collection itself), and $payload instead of [] as the change set.
Both strategies downstream expect a PersistentCollection as $subject for EVENT_COLLECTION_UPDATE:
- OTLP strategy: instanceof PersistentCollection checks fail, formatter returns null, audit entries silently dropped
- DB strategy: calls count($subject) and $subject->getSnapshot() on the entity — throws \Error (not \Exception), uncaught by the catch block
Fix: Unless the intent was to actually change the behavior for all for some reason, only change the subject/payload for ManyToMany events; preserve the original $strategy->audit($col, [], EVENT_COLLECTION_UPDATE, $ctx) call for non-ManyToMany collections.
ref: https://app.clickup.com/t/86b84w9x2