Make WordPress Core

Changeset 29119


Ignore:
Timestamp:
07/12/2014 03:53:34 AM (11 years ago)
Author:
wonderboymusic
Message:

The 2nd argument to array_unique() was added to PHP in 5.2.9, so don't use it. We have to use our own code to return unique terms when fields => all in wp_get_object_terms().

See #28843 and [28583].

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy.php

    r28976 r29119  
    23222322    $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";
    23232323
     2324    $objects = false;
    23242325    if ( 'all' == $fields || 'all_with_object_id' == $fields ) {
    23252326        $_terms = $wpdb->get_results( $query );
     
    23292330        $terms = array_merge( $terms, $_terms );
    23302331        update_term_cache( $terms );
     2332        $objects = true;
    23312333    } else if ( 'ids' == $fields || 'names' == $fields || 'slugs' == $fields ) {
    23322334        $_terms = $wpdb->get_col( $query );
     
    23452347    if ( ! $terms ) {
    23462348        $terms = array();
    2347     } else {
    2348         $terms = array_values( array_unique( $terms, SORT_REGULAR ) );
     2349    } elseif ( $objects && 'all_with_object_id' !== $fields ) {
     2350        $_tt_ids = array();
     2351        $_terms = array();
     2352        foreach ( $terms as $term ) {
     2353            if ( in_array( $term->term_taxonomy_id, $_tt_ids ) ) {
     2354                continue;
     2355            }
     2356
     2357            $_tt_ids[] = $term->term_taxonomy_id;
     2358            $_terms[] = $term;
     2359        }
     2360        $terms = $_terms;
     2361    } elseif ( ! $objects ) {
     2362        $terms = array_values( array_unique( $terms ) );
    23492363    }
    23502364    /**
Note: See TracChangeset for help on using the changeset viewer.