Commit 545d148
committed
fix(audit): populate user_name in createAuditTrailEntry
The migration (Version1Date20260423100000) relaxed NOT NULL on
`user_name` so referential-integrity rows can land without a
displayable actor. The risk: the relax applies unconditionally, so
any future code path that forgets to set `user_name` for a normal
create/update silently inserts a row with no human-readable trace
of the actor.
`createAuditTrailEntry()` (used by ImportService and downstream
consumers) was such a path — it set `user`, but never `user_name`.
Backfill from `$user->getDisplayName()` when a session user is
present, fall back to `'System'` (matches the convention in
`createAuditTrail()`).
A migration-level CHECK constraint (`(user_name IS NOT NULL) OR
(action LIKE 'referential_integrity.%')`) is the more durable
answer; this fix is the in-mapper backstop.
Refs: #1419 review (concern 9) — discussion_r31874945031 parent 07e0837 commit 545d148
1 file changed
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1505 | 1505 | | |
1506 | 1506 | | |
1507 | 1507 | | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
1508 | 1518 | | |
1509 | 1519 | | |
1510 | 1520 | | |
| |||
0 commit comments