Ticket #18828: 18828.diff
File 18828.diff, 2.5 KB (added by , 10 years ago) |
---|
-
src/wp-includes/taxonomy.php
2627 2627 } 2628 2628 2629 2629 // tt_ids queries can only be none or tr.term_taxonomy_id 2630 if ( ( 'tt_ids' == $fields) && !empty($orderby) )2630 if ( ( 'tt_ids' == $fields ) && !empty( $orderby ) ) 2631 2631 $orderby = 'tr.term_taxonomy_id'; 2632 2632 2633 if ( !empty( $orderby) )2633 if ( !empty( $orderby ) ) 2634 2634 $orderby = "ORDER BY $orderby"; 2635 2635 2636 2636 $order = strtoupper( $order ); 2637 2637 if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) ) 2638 2638 $order = 'ASC'; 2639 2639 2640 $ taxonomies = "'" . implode("', '", $taxonomies) . "'";2641 $ object_ids = implode(', ', $object_ids);2640 $_taxonomies = "'" . implode( "', '", $taxonomies ) . "'"; 2641 $_object_ids = implode( ', ', $object_ids ); 2642 2642 2643 2643 $select_this = ''; 2644 2644 if ( 'all' == $fields ) { … … 2652 2652 } elseif ( 'all_with_object_id' == $fields ) { 2653 2653 $select_this = 't.*, tt.*, tr.object_id'; 2654 2654 } 2655 $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($ taxonomies) AND tr.object_id IN ($object_ids) $orderby $order";2655 $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($_taxonomies) AND tr.object_id IN ($_object_ids) $orderby $order"; 2656 2656 2657 2657 $objects = false; 2658 2658 if ( 'all' == $fields || 'all_with_object_id' == $fields ) { … … 2671 2671 } 2672 2672 $terms = array_merge( $terms, $_terms ); 2673 2673 } elseif ( 'tt_ids' == $fields ) { 2674 $terms = $wpdb->get_col( "SELECT tr.term_taxonomy_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id IN ($object_ids) AND tt.taxonomy IN ($taxonomies) $orderby $order");2674 $terms = $wpdb->get_col( "SELECT tr.term_taxonomy_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id IN ($_object_ids) AND tt.taxonomy IN ($_taxonomies) $orderby $order" ); 2675 2675 foreach ( $terms as $key => $tt_id ) { 2676 2676 $terms[$key] = sanitize_term_field( 'term_taxonomy_id', $tt_id, 0, $taxonomy, 'raw' ); // 0 should be the term id, however is not needed when using raw context. 2677 2677 }