Closed miloslavkostir closed 4 years ago
Hi @miloslavkostir, this shouldn't technically be necessary as AuditLog only tracks changes done via the CP (where a user must be logged in). Manually creating & adding files to a project will bypass Statamic's event system completely and AuditLog won't be aware of the additions/changes.
What's the exact scenario that you're hitting this error?
Hi, try this:
id
e.g.:
title: Bug
fieldset: default
QueryException in Connection.php line 666:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'user_id' cannot be null (SQL: insert into `audit_log` (`user_id`, `data_id`, `locale`, `event`, `meta`, `snapshot`, `updated_at`, `created_at`) values (, 8ec5b14c-7b1d-4623-85e6-1cfcdb98ee0c, , Statamic\Events\Data\PageSaved,...
What happened: when you refresh site, Statamic detects page without id and edits it this way:
title: Bug
fieldset: default
id: 6033c391-867e-4d4c-a697-95aace056461
and saves it - this triggers the event Statamic\Events\Data\PageSaved
, but no user is logged in.
Nice catch @miloslavkostir! I don't think I've ever hit this edge-case as I'm always logged in during local dev 😉
Column
user_id
can be nullable: if you create content manualy (create .md file) without id, statamic automatically fill id into .md file. And there is nouser_id
. In this case you get error: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'user_id' cannot be null in ...