diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index 3e7ca95dc..f0f23f967 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -6,7 +6,7 @@ $charset_collate = ''; // Declare these as global in case schema.php is included from a function. global $wpdb, $wp_queries; -if ( $wpdb->supports_collation() ) { +if ( $wpdb->has_cap( 'collation' ) ) { if ( ! empty($wpdb->charset) ) $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; if ( ! empty($wpdb->collate) ) diff --git a/wp-includes/query.php b/wp-includes/query.php index e7b89ffc4..9756f6c04 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -1046,7 +1046,7 @@ class WP_Query { } if ( !empty($q['category__not_in']) ) { - if ( $wpdb->supports_subqueries() ) { + if ( $wpdb->has_cap( 'subqueries' ) ) { $cat_string = "'" . implode("', '", $q['category__not_in']) . "'"; $whichcat .= " AND $wpdb->posts.ID NOT IN (SELECT $wpdb->term_relationships.object_id FROM $wpdb->term_relationships WHERE $wpdb->term_relationships.term_taxonomy_id IN ($cat_string) )"; } else { diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index f14efb1fd..be29054a3 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -332,7 +332,7 @@ class wpdb { $this->ready = true; - if ( $this->supports_collation() ) { + if ( $this->has_cap( 'collation' ) ) { $collation_query = ''; if ( !empty($this->charset) ) { $collation_query = "SET NAMES '{$this->charset}'"; @@ -919,18 +919,27 @@ class wpdb { */ function supports_collation() { - return ( version_compare($this->db_version(), '4.1.0', '>=') ); + return $this->has_cap( 'collation' ); } /** - * Whether of not the database version supports sub-queries. - * - * @since 2.7 - * - * @return bool True if sub-queries are supported, false if version does not + * Generic function to determine if a database supports a particular feature + * @param string $db_cap the feature + * @param false|string|resource $dbh_or_table the databaese (the current database, the database housing the specified table, or the database of the mysql resource) + * @return bool */ - function supports_subqueries() { - return ( version_compare(mysql_get_server_info($this->dbh), '4.1.0', '>=') ); + function has_cap( $db_cap ) { + $version = $this->db_version(); + + switch ( strtolower( $db_cap ) ) : + case 'collation' : // @since 2.5.0 + case 'group_concat' : // @since 2.7 + case 'subqueries' : // @since 2.7 + return version_compare($version, '4.1', '>='); + break; + endswitch; + + return false; } /**