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

Prepared statement contains too many placeholders #946

Closed
rebbieboi opened this issue Jun 7, 2024 · 10 comments
Closed

Prepared statement contains too many placeholders #946

rebbieboi opened this issue Jun 7, 2024 · 10 comments
Labels
already fixed Already fixed and possibly already released in later versions

Comments

@rebbieboi
Copy link

rebbieboi commented Jun 7, 2024

PHP Version

8.1.28

Laravel Version

10.39.0

Package Version

13.6.4

Description

Audit is triggering a delete and in doing so logs with the error below. Yes, there is a lot of IDs sent to it for the IN condition

Prepared statement contains too many placeholders
(Connection: mysql, SQL: delete from `audits` where `audits`.`auditable_type` = App\Models\TheModel and `audits`.`auditable_id` = 4 and `audits`.`auditable_id` is not null and `id` in (

#0 /vendor/laravel/framework/src/Illuminate/Database/Connection.php(776): Illuminate\\Database\\Connection->runQueryCallback()
#1 /vendor/laravel/framework/src/Illuminate/Database/Connection.php(612): Illuminate\\Database\\Connection->run()
#2 /vendor/laravel/framework/src/Illuminate/Database/Connection.php(557): Illuminate\\Database\\Connection->affectingStatement()
#3 /vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(3617): Illuminate\\Database\\Connection->delete()
#4 /vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(1271): Illuminate\\Database\\Query\\Builder->delete()
#5 /vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php(23): Illuminate\\Database\\Eloquent\\Builder->delete()
#6 /vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php(52): Illuminate\\Database\\Eloquent\\Relations\\Relation->forwardCallTo()
#7 /vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php(517): Illuminate\\Database\\Eloquent\\Relations\\Relation->forwardDecoratedCallTo()
#8 /vendor/owen-it/laravel-auditing/src/Drivers/Database.php(37): Illuminate\\Database\\Eloquent\\Relations\\Relation->__call()
#9 /vendor/owen-it/laravel-auditing/src/Auditor.php(88): OwenIt\\Auditing\\Drivers\\Database->prune()
#10 /vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(355): OwenIt\\Auditing\\Auditor->execute()
#11 /vendor/owen-it/laravel-auditing/src/AuditableObserver.php(110): Illuminate\\Support\\Facades\\Facade::__callStatic()
#12 /vendor/owen-it/laravel-auditing/src/AuditableObserver.php(55): OwenIt\\Auditing\\AuditableObserver->dispatchAudit()
#13 /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(478): OwenIt\\Auditing\\AuditableObserver->updated()
#14 /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(286): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}()
#15 /vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(266): Illuminate\\Events\\Dispatcher->invokeListeners()
#16 /vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasEvents.php(189): Illuminate\\Events\\Dispatcher->dispatch()
#17 /vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1217): Illuminate\\Database\\Eloquent\\Model->fireModelEvent()
#18 /vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1130): Illuminate\\Database\\Eloquent\\Model->performUpdate()
#19 /vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(990): Illuminate\\Database\\Eloquent\\Model->save()

Steps To Reproduce

not sure what triggers the delete

Possible Solutions

No response

@willpower232
Copy link
Contributor

Are you able to include the rest of the stack trace for some more context? At least the lines before it reaches your app.

@rebbieboi
Copy link
Author

Are you able to include the rest of the stack trace for some more context? At least the lines before it reaches your app.

updated the post with the data requested

@willpower232
Copy link
Contributor

Thanks, are you able to confirm how many audit entries for this model you have?

@rebbieboi
Copy link
Author

Thanks, are you able to confirm how many audit entries for this model you have?

afraid I don't know how to query the 'auditable_type' column since doing like below doesn't result with anything

SELECT count(id) FROM `audits` WHERE `auditable_id` = 4 and `auditable_type` =\ 'App\Models\TheModel';

and this fails:

SELECT count(id) FROM `audits` WHERE `auditable_id` = 4 and `auditable_type` = App\Models\TheModel;

@rebbieboi
Copy link
Author

rebbieboi commented Jun 7, 2024

Thanks, are you able to confirm how many audit entries for this model you have?

EDIT: it was 74k records, I manually pruned it instead as I remember you can just use LIKE to filter using auditable_type. However, I still hope that the package can handle more records when it's deleting them automatically.

@willpower232
Copy link
Contributor

Interesting, I'll leave it for @erikn69 to investigate the specifics.

The SQL needs a double slash so

SELECT count(id) FROM `audits` WHERE `auditable_id` = 4 AND `auditable_type` = 'App\\Models\\TheModel'

@rebbieboi
Copy link
Author

Interesting, I'll leave it for @erikn69 to investigate the specifics.

The SQL needs a double slash so

SELECT count(id) FROM `audits` WHERE `auditable_id` = 4 AND `auditable_type` = 'App\\Models\\TheModel'

thank you for that! also, I set it as 'threshold' => 2500, in the config

@erikn69
Copy link
Contributor

erikn69 commented Jun 7, 2024

13.6.4

In my opinion this was already solved in later versions, I removed the whereIn: #933/files
Try v13.6.7


I'll leave it for @erikn69 to investigate the specifics.

Sorry, I can't do it at all
and most of them aren't real bugs, it's a waste of time chasing ghosts

Also, take some time to review the code, I have noticed that you have not caught up yet
Open a discussion if you don't understant something, and I will try to explain it to you, I have only contributed out of necessity, but the code is really small, and it is not complex

@parallels999 parallels999 added the already fixed Already fixed and possibly already released in later versions label Jun 7, 2024
@rebbieboi
Copy link
Author

13.6.4

In my opinion this was already solved in later versions, I removed the whereIn: #933/files Try v13.6.7

I'll leave it for @erikn69 to investigate the specifics.

Sorry, I can't do it at all and most of them aren't real bugs, it's a waste of time chasing ghosts

Also, take some time to review the code, I have noticed that you have not caught up yet Open a discussion if you don't understant something, and I will try to explain it to you, I have only contributed out of necessity, but the code is really small, and it is not complex

aye, looks like that version does fix that problem. thanks!

@willpower232
Copy link
Contributor

@erikn69 thanks for confirming, I only tagged you because I knew you had been in that part of the code very recently and would know what the issue was straight away 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
already fixed Already fixed and possibly already released in later versions
Projects
None yet
Development

No branches or pull requests

4 participants