WordPress.org

Make WordPress Core

Changeset 47451


Ignore:
Timestamp:
03/12/2020 03:53:01 PM (3 weeks ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/wp-db.php

    r47230 r47451  
    36113611     * @since 2.7.0
    36123612     *
    3613      * @return null|string Null on failure, version number on success.
     3613     * @return string|null Version number on success, null on failure.
    36143614     */
    36153615    public function db_version() {
     3616        return preg_replace( '/[^0-9.].*/', '', $this->db_server_info() );
     3617    }
     3618
     3619    /**
     3620     * Retrieves full MySQL server information.
     3621     *
     3622     * @since 5.5.0
     3623     *
     3624     * @return string|false Server info on success, false on failure.
     3625     */
     3626    public function db_server_info() {
    36163627        if ( $this->use_mysqli ) {
    36173628            $server_info = mysqli_get_server_info( $this->dbh );
     
    36193630            $server_info = mysql_get_server_info( $this->dbh );
    36203631        }
    3621         return preg_replace( '/[^0-9.].*/', '', $server_info );
     3632
     3633        return $server_info;
    36223634    }
    36233635}
  • trunk/tests/phpunit/tests/db/charset.php

    r47198 r47451  
    3030        self::$_wpdb = new WpdbExposedMethodsForTesting();
    3131
    32         if ( self::$_wpdb->use_mysqli ) {
    33             self::$server_info = mysqli_get_server_info( self::$_wpdb->dbh );
    34         } else {
    35             self::$server_info = mysql_get_server_info( self::$_wpdb->dbh );
    36         }
     32        self::$server_info = self::$_wpdb->db_server_info();
    3733    }
    3834
Note: See TracChangeset for help on using the changeset viewer.