From c8cc78671b16dea06cbc66cd7a22469e6b19e895 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 12 Mar 2020 15:55:07 +0000 Subject: [PATCH] Database: Introduce `wpdb::db_server_info()` to retrieve full MySQL server information string as supplied by `mysqli_get_server_info()`. This complements `wpdb::db_version()`, which only returns a numeric version string and strips any additional information, e.g. vendor name. Props clarinetlord, birgire, webaware, pento. Fixes #40037. See #27703. Built from https://develop.svn.wordpress.org/trunk@47451 git-svn-id: http://core.svn.wordpress.org/trunk@47238 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/version.php | 2 +- wp-includes/wp-db.php | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/wp-includes/version.php b/wp-includes/version.php index 6961414351..a007580626 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-47450'; +$wp_version = '5.5-alpha-47451'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 7239324547..a87e9621fb 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -3610,14 +3610,26 @@ class wpdb { * * @since 2.7.0 * - * @return null|string Null on failure, version number on success. + * @return string|null Version number on success, null on failure. */ public function db_version() { + return preg_replace( '/[^0-9.].*/', '', $this->db_server_info() ); + } + + /** + * Retrieves full MySQL server information. + * + * @since 5.5.0 + * + * @return string|false Server info on success, false on failure. + */ + public function db_server_info() { if ( $this->use_mysqli ) { $server_info = mysqli_get_server_info( $this->dbh ); } else { $server_info = mysql_get_server_info( $this->dbh ); } - return preg_replace( '/[^0-9.].*/', '', $server_info ); + + return $server_info; } }