HyperDB icon indicating copy to clipboard operation
HyperDB copied to clipboard

fix: `Function mysqli_ping() is deprecated since 8.4` and no longer tries to reconnect since PHP 8.2

Open macbre opened this issue 4 months ago • 4 comments

This PR resolves Deprecated: Function mysqli_ping() is deprecated since 8.4 warnings.

The change has been checked internally and works fine - the lost connection is detected, the re-connection takes place and the query is sent properly.

Resources

  • https://www.php.net/manual/en/mysqli.ping.php
  • https://php.watch/versions/8.2/mysqli-libmysql-no-longer-supported#mysqli-reconnect

macbre avatar Aug 06 '25 14:08 macbre

This proposed change doesn't really implement everything that mysqli_ping() does, which we rely upon - Pings a server connection, or tries to reconnect if the connection has gone down - the reconnect, specifically.

vnsavage avatar Aug 06 '25 18:08 vnsavage

Interesting, ex_mysql_error() also has four return statements, but SonarCube complains:

This method has 4 returns, which is more than the 3 allowed.

macbre avatar Aug 12 '25 11:08 macbre

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

sonarqubecloud[bot] avatar Aug 13 '25 11:08 sonarqubecloud[bot]

Iliya had a good observation. If we get HYPERDB_SERVER_GONE_ERROR, we shouldn't try to ping, but go straight to disconnect(): https://github.com/Automattic/HyperDB/blob/2b329ab8496071423cb910dda5531164369f7b14/db.php#L1402-L1407

And I think with that, and some testing it's good to go.

aidvu avatar Nov 19 '25 11:11 aidvu

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

sonarqubecloud[bot] avatar Nov 19 '25 11:11 sonarqubecloud[bot]