WordPress.org

Make WordPress Core

Ticket #35137: 35137.patch

File 35137.patch, 1.8 KB (added by jadpm, 6 years ago)

Patch for the bug

  • wp-includes/taxonomy.php

     
    13531353
    13541354        // Meta query support.
    13551355        $join = '';
     1356        $distinct = '';
    13561357        if ( ! empty( $args['meta_query'] ) ) {
    13571358                $mquery = new WP_Meta_Query( $args['meta_query'] );
    13581359                $mq_sql = $mquery->get_sql( 'term', 't', 'term_id' );
     
    13591360
    13601361                $join  .= $mq_sql['join'];
    13611362                $where .= $mq_sql['where'];
     1363                $distinct .= "DISTINCT";
    13621364        }
    13631365
    13641366        $selects = array();
     
    14081410
    14091411        $join .= " INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id";
    14101412
    1411         $pieces = array( 'fields', 'join', 'where', 'orderby', 'order', 'limits' );
     1413        $pieces = array( 'fields', 'join', 'where', 'distinct', 'orderby', 'order', 'limits' );
    14121414
    14131415        /**
    14141416         * Filter the terms query SQL clauses.
     
    14241426        $fields = isset( $clauses[ 'fields' ] ) ? $clauses[ 'fields' ] : '';
    14251427        $join = isset( $clauses[ 'join' ] ) ? $clauses[ 'join' ] : '';
    14261428        $where = isset( $clauses[ 'where' ] ) ? $clauses[ 'where' ] : '';
     1429        $distinct = isset( $clauses[ 'distinct' ] ) ? $clauses[ 'distinct' ] : '';
    14271430        $orderby = isset( $clauses[ 'orderby' ] ) ? $clauses[ 'orderby' ] : '';
    14281431        $order = isset( $clauses[ 'order' ] ) ? $clauses[ 'order' ] : '';
    14291432        $limits = isset( $clauses[ 'limits' ] ) ? $clauses[ 'limits' ] : '';
    14301433
    1431         $query = "SELECT $fields FROM $wpdb->terms AS t $join WHERE $where $orderby $order $limits";
     1434        $query = "SELECT $distinct $fields FROM $wpdb->terms AS t $join WHERE $where $orderby $order $limits";
    14321435
    14331436        // $args can be anything. Only use the args defined in defaults to compute the key.
    14341437        $key = md5( serialize( wp_array_slice_assoc( $args, array_keys( $defaults ) ) ) . serialize( $taxonomies ) . $query );