Skip to content
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

Model's all logs are deleted after v13.6.5 when Threshold is more 0 #950

Closed
giolaza opened this issue Jun 26, 2024 · 9 comments
Closed

Model's all logs are deleted after v13.6.5 when Threshold is more 0 #950

giolaza opened this issue Jun 26, 2024 · 9 comments
Labels
duplicate A repeated issue or entry

Comments

@giolaza
Copy link

giolaza commented Jun 26, 2024

PHP Version

8.1

Laravel Version

9.52.16

Package Version

13.6.7

Description

Default installation used.
On version 13.6.5 was working good, but after updating project to 13.6.7 logs stopped. Downgrade helped

Steps To Reproduce

Basic install.
Use 13.6.5 - all is good
Use 13.6.7 - no logs

Possible Solutions

No response

@willpower232
Copy link
Contributor

are you able to try 13.6.6 as well? are you able to share your config file?

@giolaza
Copy link
Author

giolaza commented Jun 26, 2024

checked 13.6.6 same problem
config file - audit.php is not published (default used)

additionally i see: log created for model in 13.6.5 is deleted for some reason

@willpower232
Copy link
Contributor

As per #947 this behaviour happens when the audit.threshold value is higher than 0. Is your code definitely not changing that one value at any point even if the config file isn't used? Can you output the value from php artisan tinker to confirm what it is?

@giolaza
Copy link
Author

giolaza commented Jun 26, 2024

image

@giolaza
Copy link
Author

giolaza commented Jun 26, 2024

found issue in
vendor/owen-it/laravel-auditing/src/Drivers/Database.php
here is db log:
\Illuminate\Support\Facades\DB::enableQueryLog(); $model->audits() ->latest() ->offset($threshold)->limit(PHP_INT_MAX) ->delete() > 0; $queries = \Illuminate\Support\Facades\DB::getQueryLog(); dd($queries);
delete from auditswhereaudits.auditable_type= ? andaudits.auditable_id= ? andaudits.auditable_idis not null order bycreated_at desc limit 9223372036854775807

image
image

delete method is ignoring offset method. this is reason why logs are removing("not creating")

@giolaza
Copy link
Author

giolaza commented Jun 26, 2024

#951

@parallels999
Copy link

parallels999 commented Jun 26, 2024

If audit.threshold = 0, that delete should never be executed

if (($threshold = $model->getAuditThreshold()) > 0) {

unless you have the auditThreshold property on that model, on that case, this would be a duplicate of #947
public function getAuditThreshold(): int
{
return $this->auditThreshold ?? Config::get('audit.threshold', 0);
}

@willpower232 willpower232 changed the title not logging after apdate from v13.6.5 to 13.6.7 not logging after update from v13.6.5 to 13.6.7 Jun 26, 2024
@giolaza
Copy link
Author

giolaza commented Jun 26, 2024

checked, forgot that in model I set limit for rows 1000000

@giolaza giolaza changed the title not logging after update from v13.6.5 to 13.6.7 Model's all logs are deleted after v13.6.5 when Threshold is more 0 Jun 26, 2024
@parallels999 parallels999 marked this as a duplicate of #947 Jun 26, 2024
@parallels999 parallels999 added the duplicate A repeated issue or entry label Jun 26, 2024
@erikn69
Copy link
Contributor

erikn69 commented Jun 26, 2024

Hi, test new changes on #948

@erikn69 erikn69 closed this as completed Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate A repeated issue or entry
Projects
None yet
Development

No branches or pull requests

4 participants