Make WordPress Core

Changeset 38277


Ignore:
Timestamp:
08/18/2016 07:14:52 PM (8 years ago)
Author:
boonebgorges
Message:

In is_object_in_term(), return error object rather than caching it.

This change prevents an error object from being stored in the cache,
and prevents notices from being thrown when plucking term IDs to put
into the relationship cache.

See #32044, #36814.

Props rpayne7264.
Fixes #37721.

Location:
trunk
Files:
2 edited

Legend:

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

    r38162 r38277  
    42754275    if ( false === $object_terms ) {
    42764276        $object_terms = wp_get_object_terms( $object_id, $taxonomy, array( 'update_term_meta_cache' => false ) );
     4277        if ( is_wp_error( $object_terms ) ) {
     4278            return $object_terms;
     4279        }
     4280
    42774281        wp_cache_set( $object_id, wp_list_pluck( $object_terms, 'term_id' ), "{$taxonomy}_relationships" );
    42784282    }
  • trunk/tests/phpunit/tests/term/isObjectInTerm.php

    r35242 r38277  
    147147        $this->assertSame( $num_queries, $wpdb->num_queries );
    148148    }
     149
     150    /**
     151     * @ticket 37721
     152     */
     153    public function test_invalid_taxonomy_should_return_wp_error_object() {
     154        $this->assertWPError( is_object_in_term( 12345, 'foo', 'bar' ) );
     155    }
    149156}
Note: See TracChangeset for help on using the changeset viewer.