fix: `Function mysqli_ping() is deprecated since 8.4` and no longer tries to reconnect since PHP 8.2
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
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.
Interesting, ex_mysql_error() also has four return statements, but SonarCube complains:
This method has 4 returns, which is more than the 3 allowed.
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
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.
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