WARNING: MYSQL_OPT_RECONNECT is deprecated and will be removed in a future version
bgabler opened this issue · comments
Bug Report
- Yes, I reviewed the contribution guidelines.
- Yes, more specifically, I reviewed the guidelines on how to write clear bug reports.
Describe the current, buggy behavior
When working with MySQL Ver 8.0.35, WP CLI is throwing the following warning when running MySQL related commands:
$ wp option get blogname
WARNING: MYSQL_OPT_RECONNECT is deprecated and will be removed in a future version.
My Blog
According to the documentation, beginning with MySQL 8.0.34, the automatic reconnection feature is deprecated.
The related MYSQL_OPT_RECONNECT option is still available but now returns a deprecation warning to the standard error output if your application calls the mysql_get_option() or mysql_options() function with the option, even when setting it to false.
Expect automatic reconnection functionality to be removed in a future version of MySQL.
https://dev.mysql.com/doc/c-api/8.0/en/c-api-auto-reconnect.html
https://dev.mysql.com/doc/c-api/8.0/en/mysql-options.html
Describe how other contributors can replicate this bug
The bug currently happens with the latest version of WP CLI on the following env:
- MySQL 8.0.35
- mysqlnd 8.0.34+
- php 7.4+
Describe what you expect as the correct outcome
Support for MySQL 8.0.34+ and MySQL 8.1.0+ client libraries as well as future releases that remove automatic-reconnection control.
Let us know what environment you are running this on
- MySQL 8.0.35
- php 7.4.33
- mysqli 8.0.35
OS: Linux 4.18.0-425.13.1.lve.el8.x86_64 #1 SMP Mon Feb 27 15:23:24 EST 2023 x86_64
Shell: /usr/bin/bash
PHP binary: /opt/alt/php74/usr/bin/php
PHP version: 7.4.33
php.ini used: /opt/alt/php74/etc/php.ini
MySQL binary: /usr/bin/mysql
MySQL version: mysql Ver 8.0.35 for Linux on x86_64 (MySQL Community Server - GPL)
SQL modes:
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: /home/lq4mgbg/public_html
WP-CLI packages dir:
WP-CLI cache dir: /home/lq4mgbg/.wp-cli/cache
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.9.0
Thanks for the report, @bgabler
wp option get
simply calls get_option()
under the hood:
This particular command uses WordPress exclusively for database interactions.
My guess is that the warning is coming from WordPress itself, or a custom db.php
drop-in. Does this ring any bells?
Hi @danielbachhuber,
Thanks for taking a look :)
It happens to every site on our platform and we don’t use a custom drop in. It seems to be any call we use with WP cli that requires reading from the db.
Sounds like it may be related to WP Core, just odd we don’t see it in any error logs from HTTP requests.
Do you have MYSQL_CLIENT_FLAGS
defined? Or maybe MYSQL_OPT_RECONNECT
is somehow specified in my.cnf
? https://github.com/WordPress/wordpress-develop/blob/43d2455dc68072fdd43c3c800cc8c32590f23cbe/src/wp-includes/class-wpdb.php#L1956
Nope, everything I read online states this comes directly from MySQL server as its going to be deprecated in future releases all together, but only when using mysqlnd client 8.0.34+.
If we use an older mysqlnd client library, it does not occur.
If you compile PHP with that, you should be able to reproduce.
I am seeing this error now as well and I did not make any changes. I am asking the hosting service if changes were made. But this just started this morning.
MySQL version: 8.0.36, PHP: 7.4, WP version: 6.2.3
Me too :
MySQL version: 8.0.36, PHP: 7.4, WP version: 6.4.3
Constant deprecated warning output when running a WP bash installation script: Excerpt follows:
Downloading WordPress 6.4.3 (en_US)...
Using cached file '/home/sitename/.wp-cli/cache/core/wordpress-6.4.3-en_US.tar.gz'...
Success: WordPress downloaded.
Writing the wp-config.php file, and adding standard additions/options to it
**WARNING: MYSQL_OPT_RECONNECT is deprecated and will be removed in a future version.**
Success: Generated 'wp-config.php' file.
Running install
**WARNING: MYSQL_OPT_RECONNECT is deprecated and will be removed in a future version.**
Success: WordPress installed successfully.
We have a hosting company and I am receiving an average of 400 emails a day with this message. (cron jobs)
All with different wordpress (different templates, different plugins, different versions...).
So it seems to be a generalized problem
WARNING: MYSQL_OPT_RECONNECT is deprecated and will be removed in a future version.
mysql Ver 8.0.36
PHP 7 & 8 & 8.1
WP latest versions...
I did some research into this, and to me it looks like this is not something WP-CLI is causing or that WP-CLI can fix.
Since the MYSQL_OPT_RECONNECT
option has been, the deprecated warning is not only shown when someone is trying to use the reconnect feature, but rather anytime the option is being referenced - even if it is being set to false
.
WP-CLI does not add this option to database calls, and I did not find any traces of it in WordPress Core either. So this either comes from extensions (plugins/themes), which is unlikely, or more probably it comes from the environment. It might be set in some configuration files, or it could be automatically added by certain driver libraries.
Most users affected by this have reported that it went away after certain system updates.