-
Notifications
You must be signed in to change notification settings - Fork 25
fix: Function mysqli_ping() is deprecated since 8.4 and no longer tries to reconnect since PHP 8.2
#165
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
base: trunk
Are you sure you want to change the base?
fix: Function mysqli_ping() is deprecated since 8.4 and no longer tries to reconnect since PHP 8.2
#165
Changes from all commits
3d87f8d
f9ce2d2
20a584a
ead28a0
e9e4928
46f74e0
95e5304
2b329ab
8a51769
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1402,8 +1402,8 @@ public function should_mysql_ping() { | |
| // MySQL server has gone away | ||
| if ( isset( $this->dbhname_heartbeats[ $this->dbhname ]['last_errno'] ) && | ||
| HYPERDB_SERVER_GONE_ERROR == $this->dbhname_heartbeats[ $this->dbhname ]['last_errno'] ) { | ||
| unset( $this->dbhname_heartbeats[ $this->dbhname ]['last_errno'] ); | ||
| return true; | ||
| $this->disconnect( $this->dbhname ); | ||
| return false; | ||
| } | ||
|
|
||
| // More than 0.1 seconds of inactivity on that dbhname | ||
|
|
@@ -1556,7 +1556,20 @@ public function ex_mysql_ping( $dbh ) { | |
| return @mysql_ping( $dbh ); | ||
| } | ||
|
|
||
| return @mysqli_ping( $dbh ); | ||
| // Deprecated: Function mysqli_ping() is deprecated since 8.4 | ||
macbre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // The mysqli.reconnect php.ini setting had been ignored by the mysqlnd driver, and was removed as of PHP 8.2.0. | ||
| if ( version_compare( PHP_VERSION, '8.2.0', '<' ) ) { | ||
| return @mysqli_ping( $dbh ); | ||
| } | ||
|
|
||
| $res = $this->ex_mysql_query( 'SELECT /* hyperdb::ex_mysql_ping */ 1', $dbh ); | ||
| if ( is_object( $res ) && 1 === $res->num_rows ) { | ||
| // The "ping" query was enough, the database connection is still there. | ||
| return true; | ||
| } | ||
|
|
||
| // Let the hyperdb logic reconnect us. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still thinking about this... @vnsavage wanted the reconnect logic here VS letting The reconnect was removed and wasn't working since at least 8.2. Considering that the fallback was good enough, not sure what value is there in having the reconnect re-implemented. In theory, it would be a bit faster then going through all of the logic for finding a server to connect to. |
||
| return false; | ||
| } | ||
|
|
||
| public function ex_mysql_affected_rows( $dbh ) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aidvu - like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. I don't think that's enough. It needs to behave the same way as this block:
HyperDB/db.php
Lines 523 to 532 in 8a51769
So we either move the
HYPERDB_SERVER_GONE_ERRORcheck there, or anddisconnect/breakforPHP < 8.0.0or we rewrite the check a bit.