Argument PDOStatement Errors

Problem

When performing MySQL®-intensive actions, you see one of the following errors:

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

or

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

These generally occur during the daily automation cron tasks, when importing TLDs and pricing, or when syncing accounts into WHMCS from a server.

Cause

This may be due to the following causes:

  • The Module Log is enabled and the system is logging a large amount of data to the MySQL database.
  • The wait_timeout and interactive_timeout variables in the MySQL server configuration are too low to complete the request.

Solution

Disable the Module Log

We recommend disabling the Module Log unless you are actively troubleshooting a module-related issue. We also recommend using the the default values for the wait_timeout and interactive_timeout variables in the MySQL server configuration.

To disable the Module Log:

  1. Go to Configuration () > System Logs.
  2. Click Module Log in the left-side menu.
  3. Click Disable Debug Logging.

Correct the MySQL Server Configuration

To update the wait_timeout and interactive_timeout values to use their defaults:

  1. Open your MySQL server’s /etc/mysql/my.cnf file.

  2. Find the wait_timeout and interactive_timeout values:

    [mysqld]
    wait_timeout=28800
    interactive_timeout=28800
    
  3. Set both values to 28800 if they do not already use this value.

    For more information, see MySQL’s wait_timeout and interactive_timeout documentation.

  4. Save the changes to the file.

  5. Restart your MySQL server by running the following command:

    service mysql restart

For help, contact your hosting provider or system administrator.

Last modified: May 28, 2024