diff --git a/wp-includes/class-wp-meta-query.php b/wp-includes/class-wp-meta-query.php index ac1da7d1f6..f66b2fac5f 100644 --- a/wp-includes/class-wp-meta-query.php +++ b/wp-includes/class-wp-meta-query.php @@ -679,11 +679,13 @@ class WP_Meta_Query { case 'REGEXP': $operator = $meta_compare_key; if ( isset( $clause['type_key'] ) && 'BINARY' === strtoupper( $clause['type_key'] ) ) { - $cast = 'BINARY'; + $cast = 'BINARY'; + $meta_key = "CAST($alias.meta_key AS BINARY)"; } else { - $cast = ''; + $cast = ''; + $meta_key = "$alias.meta_key"; } - $where = $wpdb->prepare( "$alias.meta_key $operator $cast %s", trim( $clause['key'] ) ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared + $where = $wpdb->prepare( "$meta_key $operator $cast %s", trim( $clause['key'] ) ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared break; case '!=': @@ -705,12 +707,14 @@ class WP_Meta_Query { case 'NOT REGEXP': $operator = $meta_compare_key; if ( isset( $clause['type_key'] ) && 'BINARY' === strtoupper( $clause['type_key'] ) ) { - $cast = 'BINARY'; + $cast = 'BINARY'; + $meta_key = "CAST($subquery_alias.meta_key AS BINARY)"; } else { - $cast = ''; + $cast = ''; + $meta_key = "$subquery_alias.meta_key"; } - $meta_compare_string = $meta_compare_string_start . "AND $subquery_alias.meta_key REGEXP $cast %s " . $meta_compare_string_end; + $meta_compare_string = $meta_compare_string_start . "AND $meta_key REGEXP $cast %s " . $meta_compare_string_end; $where = $wpdb->prepare( $meta_compare_string, $clause['key'] ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared break; } diff --git a/wp-includes/version.php b/wp-includes/version.php index c4e7f9cd18..ae23582f07 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-53900'; +$wp_version = '6.1-alpha-53901'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.