Make WordPress Core


Ignore:
Timestamp:
12/10/2015 03:34:51 AM (9 years ago)
Author:
boonebgorges
Message:

Improve handling for WP_Error objects in get_the_terms().

wp_get_object_terms() can return a WP_Error object. As such, the
get_the_terms() cache wrapper should handle them properly. To wit:

  • Don't try to map an error object to get_term(). Introduced in [35032].
  • Don't cache an error object as taxonomy relationships. Introduced in at least [16487], maybe earlier.

Props stephenharris.
Fixes #34723.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term.php

    r35246 r35850  
    628628        $this->assertWPError( $cat_id2 );
    629629    }
     630
     631    /**
     632     * @ticket 34723
     633     */
     634    function test_get_the_terms_should_return_wp_error_when_taxonomy_is_unregistered() {
     635        $p = self::$post_ids[0];
     636        $terms = get_the_terms( $p, 'this-taxonomy-does-not-exist' );
     637        $this->assertTrue( is_wp_error( $terms ) );
     638    }
    630639}
Note: See TracChangeset for help on using the changeset viewer.