Guides & TutorialsTroubleshooting Common ErrorsTroubleshooting an Argument 1 passed ... must be an instance of PDOStatement Error

Troubleshooting an Argument 1 passed ... must be an instance of PDOStatement Error

Symptom

When performing MySQL-intensive actions, the following errors may be encountered:

TypeError: Argument 1 passed to Illuminate\Database\Connection::prepared() must be an instance of PDOStatement, bool given
TypeError: Argument 1 passed to WHMCS\Database\MysqlCompat::setLastStatement() must be an instance of PDOStatement or null, bool 

This has been observed during the daily automation cron tasks, performing TLD & Pricing import or Syncing accounts into WHMCS from a server.

Cause

1. The Module Debug Log is enabled and the action being performed is logging a lot of data to the MySQL Database.

2. The wait_timeout and interactive_timeout variables in the MySQL server configuration are too low to complete the request

Solutions

Disable the Module Debug Log

We recommend the Module Debug Log is disabled under normal operations and that the MySQL server configuration has the default values for wait_timeout and interactive_timeout variables set.

Please ensure the Module Debug Log is disabled unless a module issue is currently being investigated:

1. Navigate to Configuration > System Logs

Configuration > System Logs

2. Click Module Log on the left-hand menu:

Module Log

3. Click the Disable Module Log button:

Disable Debug Logging Button

Correct MySQL Server Configuration

It may be necessary to work with your server admin or hosting provider to make the following correction to the MySQL server configuration

1. Edit your MySQL server's /etc/mysql/my.cnf file

2. Observe the wait_timeout and interactive_timeout values:

[mysqld]
wait_timeout=28800
interactive_timeout=28800

3. Assert the default value of 28800 is set for both:

4. Allowing an insufficient timeout for either of these system variables will cause this error. Therefore the recommended default values should be restored.

5. Save the changes and restart your MySQL server:

service mysql restart