Make WordPress Core

Ticket #18828: taxonomy_wp_get_object_terms.php.patch

File taxonomy_wp_get_object_terms.php.patch, 2.2 KB (added by doublesharp, 8 years ago)

wp_get_object_terms filter fix for $taxonomies and $object_ids

  • wp-includes/taxonomy.php

     
    22542254        if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) )
    22552255                $order = 'ASC';
    22562256
    2257         $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    2258         $object_ids = implode(', ', $object_ids);
     2257        $_taxonomies = "'" . implode("', '", $taxonomies) . "'";
     2258        $_object_ids = implode(', ', $object_ids);
    22592259
    22602260        $select_this = '';
    22612261        if ( 'all' == $fields )
     
    22692269        else if ( 'all_with_object_id' == $fields )
    22702270                $select_this = 't.*, tt.*, tr.object_id';
    22712271
    2272         $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";
     2272        $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_in) AND tr.object_id IN ($_object_ids) $orderby $order";
    22732273
    22742274        if ( 'all' == $fields || 'all_with_object_id' == $fields ) {
    22752275                $_terms = $wpdb->get_results( $query );
     
    22862286                }
    22872287                $terms = array_merge( $terms, $_terms );
    22882288        } else if ( 'tt_ids' == $fields ) {
    2289                 $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");
     2289                $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_in) $orderby $order");
    22902290                foreach ( $terms as $key => $tt_id ) {
    22912291                        $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.
    22922292                }