-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Audited logs deleted on fresh install with threshold set to > 0 #947
Comments
There are tests for that functionality, also some relateds #946, #933 laravel-auditing/tests/Functional/AuditingTest.php Lines 292 to 310 in 22682dd
Maybe laravel-auditing/src/Drivers/Database.php Lines 25 to 30 in 22682dd
Try 13.6.5, does it work in that version? |
I have the same issue when using this package in my development setup. When running 13.6.5 (as mentioned above), the threshold appears to work as expected. In the latest version, setting the threshold to anything other than 0, removes all audits for the model being audited. I see that the tests pass when I check out master to my dev environment. Changing the test driver from
Edit to add that my MySQL version was 8.1.0 when I checked this. More info (when running against MySQL): If I change select * from `audit_testing` where `audit_testing`.`auditable_type` = ? and `audit_testing`.`auditable_id` = ? and `audit_testing`.`auditable_id` is not null order by `created_at` desc limit 9223372036854775807 offset 10 When I use the query log (DB::enableQueryLog() & DB::getQueryLog()) to get the executed statement I can see that the offset is not included: delete from `audit_testing` where `audit_testing`.`auditable_type` = ? and `audit_testing`.`auditable_id` = ? and `audit_testing`.`auditable_id` is not null order by `created_at` desc limit 922337203685477580 The SQLite query is generated appropriately: delete from "audit_testing" where "rowid" in (select "audit_testing"."rowid" from "audit_testing" where "audit_testing"."auditable_type" = ? and "audit_testing"."auditable_id" = ? and "audit_testing"."auditable_id" is not null order by "created_at" desc limit 9223372036854775807 offset 10 Notice the sub select in the delete statement for SQLite. Seems like this is not implemented for some reason in MySQLGrammar compared with SQLiteGrammar in the Framework itself. |
src/Illuminate/Database/Query/Grammars/MySqlGrammar.php#L117-L145 |
Hi, try #948 |
Apologies @parallels999 — I've been away on business for a few days and didn't have much time to answer this. Looks like there's a promising PR in the pipeline however, so thanks to @erikn69 / @jamiewatsonuk for their contribs 👍 |
+1 can confirm this is an issue if you have a threshold set after the latest update |
That has already been established, waiting for someone to confirm that the fix works |
+1 Confirmed that it is a problem if you have a threshold set after v13.6.5. |
PHP Version
8.3
Laravel Version
11.x
Package Version
13.6.7
Description
Hi there, firstly thanks for the great package!
I'm not sure if this is something I'm doing or what, but I've just installed a fresh copy, followed the instructions to the letter, and it was refusing to keep audit log entries when I'd tried saving in the following manners:
->save()
method on a model instance (withconsole
set totrue
in the config)I'd stopped short of making a custom controller just to test this, as I had added the following to my model:
And that dump was coming through on the above save methods.
I'd also added an event listener for
OwenIt\Auditing\Events\Auditing
which was dumping out each time I tried the above save methods as well.It wasn't until I'd set the
threshold
option back to0
(from my preference of100
) that it started actually logging anything.I've tested this with the threshold at various values and it seems that the prune method might have a bug in it as when the value is anything other than
0
, the entire log for that model (and only that model instance, it seems) is removed on each audit event.Steps To Reproduce
Possible Solutions
No response
The text was updated successfully, but these errors were encountered: