From 8c2c762e23bc2400b5e39400634c0b9e2e7330d2 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Wed, 8 Nov 2023 20:31:34 +0000 Subject: [PATCH] Database: Reinstate wpdb::$use_mysqli property. Partial revert of [56475] to reinstate the private `wpdb::$use_mysqli` property and set to its default to `true`. This private property was / is accessible through the magic methods. Though Core's usage of this property was removed by [56475], plugins are using the property. Reinstating it resolves the BC break. Follow up to [56475]. Props jason_the_adams, joemcgill, johnbillion, johnjamesjacoby, jrf, rajinsharwar, renehermi. Fixes #59846. git-svn-id: https://develop.svn.wordpress.org/trunk@57089 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wpdb.php | 15 +++++++++++++++ tests/phpunit/tests/db.php | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/wp-includes/class-wpdb.php b/src/wp-includes/class-wpdb.php index 39c467f03182d..baba39d91f4d9 100644 --- a/src/wp-includes/class-wpdb.php +++ b/src/wp-includes/class-wpdb.php @@ -690,6 +690,21 @@ class wpdb { */ private $allow_unsafe_unquoted_parameters = true; + /** + * Whether to use the mysqli extension over mysql. This is no longer used as the mysql + * extension is no longer supported. + * + * Default true. + * + * @since 3.9.0 + * @since 6.4.0 This property was removed. + * @since 6.4.1 This property was reinstated and its default value was changed to true. + * The property is no longer used in core but may be accessed externally. + * + * @var bool + */ + private $use_mysqli = true; + /** * Whether we've managed to successfully connect at some point. * diff --git a/tests/phpunit/tests/db.php b/tests/phpunit/tests/db.php index 21c34cbadb856..984fe6765cc02 100644 --- a/tests/phpunit/tests/db.php +++ b/tests/phpunit/tests/db.php @@ -2469,4 +2469,17 @@ public function data_parse_db_host() { ), ); } + + /** + * This private property is no longer used but needs to be retained as it can be + * accessed externally due to the `__get()` magic method. + * + * @ticket 59118 + * @ticket 59846 + */ + public function test_use_mysqli_property_access() { + global $wpdb; + + $this->assertTrue( $wpdb->use_mysqli ); + } }