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

WARNING: MYSQL_OPT_RECONNECT is deprecated and will be removed in a future version #5889

Open
2 tasks done
bgabler opened this issue Dec 26, 2023 · 9 comments
Open
2 tasks done

Comments

@bgabler
Copy link

bgabler commented Dec 26, 2023

Bug Report

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

Screenshot 2023-12-26 at 1 00 54 PM

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
@danielbachhuber
Copy link
Member

Thanks for the report, @bgabler

wp option get simply calls get_option() under the hood:

https://github.com/wp-cli/entity-command/blob/eac6762e75355ebaa6e22c086f74b0c5b5f65774/src/Option_Command.php#L74-L84

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?

@bgabler
Copy link
Author

bgabler commented Jan 3, 2024

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.

@danielbachhuber
Copy link
Member

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

@bgabler
Copy link
Author

bgabler commented Jan 3, 2024

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.

@ajbastien
Copy link

ajbastien commented Jan 29, 2024

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

@mayersdesign
Copy link

mayersdesign commented Feb 14, 2024

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.

@CristianDeluxe
Copy link

CristianDeluxe commented Mar 9, 2024

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...

@schlessera
Copy link
Member

schlessera commented Mar 14, 2024

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.

@Carlos-mb
Copy link

This has started happening in two of my sites. Moodle with PHP 8.x and WordPress with PHP 7.4.

I guess the hoster has change something but I don't know what and I don't know what to say them what to check.

I'll pay atention to this issue.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants