Skip to content

Commit

Permalink
Database: Reinstate wpdb::$use_mysqli property.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hellofromtonya committed Nov 8, 2023
1 parent 2130a90 commit 8c2c762
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/wp-includes/class-wpdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
13 changes: 13 additions & 0 deletions tests/phpunit/tests/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}

0 comments on commit 8c2c762

Please sign in to comment.