From 97720253b94674495c9ce05b267466358194e9a6 Mon Sep 17 00:00:00 2001 From: Lena Stergatou Date: Wed, 5 Apr 2023 17:34:00 +0300 Subject: [PATCH 1/2] Update db.php Fix for WP 6.1+ and PHP 8.1 --- db.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/db.php b/db.php index 0dd47c6..67147fb 100644 --- a/db.php +++ b/db.php @@ -4,7 +4,7 @@ Plugin URI: https://premium.wpmudev.org/project/multi-db/ Description: Allows you to scale your standard Multisite install to allow for millions of blogs and segment your database across multiple physical servers. Author: WPMU DEV -Version: 4.0 +Version: 5.0 Author URI: http://premium.wpmudev.org/ WDP ID: 1 @@ -154,9 +154,17 @@ function add_dc_ip( $ip, $dc ) { // To allow extending of database class $wpdb = 'we-need-to-pre-populate-this-variable'; -require_once ABSPATH . WPINC . '/wp-db.php'; -if ( !defined( 'MULTI_DB_VERSION' ) ) define( 'MULTI_DB_VERSION', '4.0' ); +//For WP 6.1+. File wp-db.php is deprecated since WordPress version 6.1.0 +//@since 5.0 +global $wp_version; +if ( version_compare($wp_version,'6.1.0') >= 0) { + require_once ABSPATH . WPINC . '/class-wpdb.php'; +} else { + require_once ABSPATH . WPINC . '/wp-db.php'; +} + +if ( !defined( 'MULTI_DB_VERSION' ) ) define( 'MULTI_DB_VERSION', '5.0' ); if ( !defined( 'WP_USE_MULTIPLE_DB' ) ) define( 'WP_USE_MULTIPLE_DB', false ); if ( !defined( 'DB_SCALING' ) ) define( 'DB_SCALING', '16' ); if ( !defined( 'EZSQL_VERSION' ) ) define( 'EZSQL_VERSION', 'WP1.25' ); @@ -364,6 +372,14 @@ public function get_all_tables( $tables ) { * @return boolean|resource The database connection resource on success, otherwise FALSE. */ public function db_connect( $query = 'SELECT 1' ) { + /* + * Set the MySQLi error reporting off because WordPress handles its own. + * This is due to the default value change from `MYSQLI_REPORT_OFF` + * to `MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT` in PHP 8.1. + *@since version 5.0 + */ + mysqli_report( MYSQLI_REPORT_OFF ); + if ( empty( $query ) ) { return false; } From de0cf76c7501bf3e29bc39cfcb991b2606a65f00 Mon Sep 17 00:00:00 2001 From: Lena Stergatou Date: Thu, 22 Jun 2023 15:20:18 +0300 Subject: [PATCH 2/2] Update db.php Change version to 4.0.1 --- db.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db.php b/db.php index 67147fb..2ad5774 100644 --- a/db.php +++ b/db.php @@ -4,7 +4,7 @@ Plugin URI: https://premium.wpmudev.org/project/multi-db/ Description: Allows you to scale your standard Multisite install to allow for millions of blogs and segment your database across multiple physical servers. Author: WPMU DEV -Version: 5.0 +Version: 4.0.1 Author URI: http://premium.wpmudev.org/ WDP ID: 1