Opened 2 years ago
Closed 2 years ago
#56484 closed enhancement (fixed)
Site Health: Use $wpdb->db_server_info() to retrieve database server type
Reported by: | SergeyBiryukov | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Site Health | Keywords: | has-patch commit |
Focuses: | Cc: |
Description (last modified by )
WP_Site_Health::prepare_sql_data()
has this fragment, introduced in [44986] / #46573:
if ( $wpdb->use_mysqli ) { // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_server_info $mysql_server_type = mysqli_get_server_info( $wpdb->dbh ); } else { // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_server_info,PHPCompatibility.Extensions.RemovedExtensions.mysql_DeprecatedRemoved $mysql_server_type = mysql_get_server_info( $wpdb->dbh ); }
This can be replaced with:
$mysql_server_type = $wpdb->db_server_info();
The db_server_info()
method has the exact same code and is available as of [47451] / #40037.
Attachments (1)
Change History (8)
#4
@
2 years ago
Thanks for the patch! It looks good to me too.
I had a concern about whether this method would be available in custom database drop-ins (wp-content/db.php
), but it looks like they are loaded after wpdb, and are supposed to extend the class, rather than completely replace it, though technically the latter is possible too.
@Clorith, do you think this change is safe as is, or should we check if the method exists, just in case, and fall back to the current code if it doesn't? Upon a quick check, popular drop-ins like HyperDB extend the wpdb
class, so the patch seems good to go.
Hi @SergeyBiryukov , Thank you for the ticket I replaced the function fragment in WP_Site_Health::prepare_sql_data() .