: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Called when WordPress is generating the table scheme.
* Use `wpdb::has_cap( 'collation' )`.
* @deprecated 3.5.0 Use wpdb::has_cap()
* @return bool True if collation is supported, false if not.
public function supports_collation() {
_deprecated_function( __FUNCTION__, '3.5.0', 'wpdb::has_cap( \'collation\' )' );
return $this->has_cap( 'collation' );
* Retrieves the database character collate.
* @return string The database character collate.
public function get_charset_collate() {
if ( ! empty( $this->charset ) ) {
$charset_collate = "DEFAULT CHARACTER SET $this->charset";
if ( ! empty( $this->collate ) ) {
$charset_collate .= " COLLATE $this->collate";
* Determines whether the database or WPDB supports a particular feature.
* Capability sniffs for the database server and current version of WPDB.
* Database sniffs are based on the version of MySQL the site is using.
* WPDB sniffs are added as new features are introduced to allow theme and plugin
* developers to determine feature support. This is to account for drop-ins which may
* introduce feature support at a different time to WordPress.
* @since 4.1.0 Added support for the 'utf8mb4' feature.
* @since 4.6.0 Added support for the 'utf8mb4_520' feature.
* @since 6.2.0 Added support for the 'identifier_placeholders' feature.
* @since 6.6.0 The `utf8mb4` feature now always returns true.
* @see wpdb::db_version()
* @param string $db_cap The feature to check for. Accepts 'collation', 'group_concat',
* 'subqueries', 'set_charset', 'utf8mb4', 'utf8mb4_520',
* or 'identifier_placeholders'.
* @return bool True when the database feature is supported, false otherwise.
public function has_cap( $db_cap ) {
$db_version = $this->db_version();
$db_server_info = $this->db_server_info();
* Account for MariaDB version being prefixed with '5.5.5-' on older PHP versions.
* Note: str_contains() is not used here, as this file can be included
* directly outside of WordPress core, e.g. by HyperDB, in which case
* the polyfills from wp-includes/compat.php are not loaded.
if ( '5.5.5' === $db_version && false !== strpos( $db_server_info, 'MariaDB' )
&& PHP_VERSION_ID < 80016 // PHP 8.0.15 or older.
// Strip the '5.5.5-' prefix and set the version to the correct value.
$db_server_info = preg_replace( '/^5\.5\.5-(.*)/', '$1', $db_server_info );
$db_version = preg_replace( '/[^0-9.].*/', '', $db_server_info );
switch ( strtolower( $db_cap ) ) {
case 'collation': // @since 2.5.0
case 'group_concat': // @since 2.7.0
case 'subqueries': // @since 2.7.0
return version_compare( $db_version, '4.1', '>=' );
return version_compare( $db_version, '5.0.7', '>=' );
case 'utf8mb4': // @since 4.1.0
case 'utf8mb4_520': // @since 4.6.0
return version_compare( $db_version, '5.6', '>=' );
case 'identifier_placeholders': // @since 6.2.0
* As of WordPress 6.2, wpdb::prepare() supports identifiers via '%i',
* e.g. table/field names.
* Retrieves a comma-separated list of the names of the functions that called wpdb.
* @return string Comma-separated list of the calling functions.
public function get_caller() {
return wp_debug_backtrace_summary( __CLASS__ );
* Retrieves the database server version.
* @return string|null Version number on success, null on failure.
public function db_version() {
return preg_replace( '/[^0-9.].*/', '', $this->db_server_info() );
* Returns the version of the MySQL server.
* @return string Server version as a string.
public function db_server_info() {
return mysqli_get_server_info( $this->dbh );