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

Fix PHP 8.4 mysqli_ping deprecation and error code change #190

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions ludicrousdb/includes/class-ludicrousdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -1606,7 +1606,7 @@ public function check_connection( $die_on_disconnect = true, $dbh_or_table = fal
if (
$this->dbh_type_check( $dbh )
&&
mysqli_ping( $dbh )
mysqli_query( $dbh, 'DO 1' ) !== false
) {
return true;
}
Expand Down Expand Up @@ -1785,9 +1785,9 @@ public function query( $query ) {
&&
( $this->last_found_rows_result instanceof mysqli_result )
) {
$this->result = $this->last_found_rows_result;
$elapsed = 0;

$this->result = $this->last_found_rows_result;
$this->last_found_rows_result = null;
$elapsed = 0;
} else {
$this->dbh = $this->db_connect( $query );

Expand All @@ -1803,7 +1803,7 @@ public function query( $query ) {

++$this->num_queries;

if ( preg_match( '/^\s*SELECT\s+([A-Z_]+\s+)*SQL_CALC_FOUND_ROWS\s/i', $query ) ) {
if ( preg_match( '/^\s*SELECT\s+([A-Z_]+\s+)*SQL_CALC_FOUND_ROWS\s/i', $query ) && false !== $this->result ) {
if ( false === strpos( $query, 'NO_SELECT_FOUND_ROWS' ) ) {
$this->timer_start();
$this->last_found_rows_result = $this->_do_query( 'SELECT FOUND_ROWS()', $this->dbh );
Expand Down Expand Up @@ -2384,7 +2384,7 @@ public function should_mysql_ping( $dbhname = '' ) {
if (
! empty( $this->dbhname_heartbeats[ $dbhname ]['last_errno'] )
&&
( DB_SERVER_GONE_ERROR === $this->dbhname_heartbeats[ $dbhname ]['last_errno'] )
( in_array( $this->dbhname_heartbeats[ $dbhname ]['last_errno'], array( 2006, 4031 ), true ) )
) {

// Also clear the last error
Expand Down
Loading