Parsed: 127420

  public function has_cap( $db_cap ) {
    $db_version     = $this->wpdb::db_version();
    $db_server_info = $this->db_server_info();

    // Account for MariaDB version being prefixed with '5.5.5-' on older PHP versions.
    if ( '5.5.5' === $db_version && str_contains( $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', '>=' );
      case 'set_charset':
        return version_compare( $db_version, '5.0.7', '>=' );
      case 'utf8mb4':      // @since 4.1.0
        if ( version_compare( $db_version, '5.5.3', '<' ) ) {
          return false;
        }
        if ( $this->use_mysqli ) {
          $client_version = mysqli_get_client_info();
        } else {
          $client_version = mysql_get_client_info();
        }

        /*
				 * libmysql has supported utf8mb4 since 5.5.3, same as the MySQL server.
				 * mysqlnd has supported utf8mb4 since 5.0.9.
				 */
        if ( false !== strpos( $client_version, 'mysqlnd' ) ) {
          $client_version = preg_replace( '/^\D+([\d.]+).*/', '$1', $client_version );
          return version_compare( $client_version, '5.0.9', '>=' );
        } else {
          return version_compare( $client_version, '5.5.3', '>=' );
        }
      case 'utf8mb4_520': // @since 4.6.0
        return version_compare( $db_version, '5.6', '>=' );
    }

    return false;
  }