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.

Merges [38277] to the 4.6 branch.

Props rpayne7264.
Fixes #37721.

Built from https://develop.svn.wordpress.org/branches/4.6@38346


git-svn-id: http://core.svn.wordpress.org/branches/4.6@38287 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2016-08-24 09:20:36 +00:00
parent a624b1c967
commit 97095d54c3
2 changed files with 5 additions and 1 deletions

View File

@ -4274,6 +4274,10 @@ function is_object_in_term( $object_id, $taxonomy, $terms = null ) {
$object_terms = get_object_term_cache( $object_id, $taxonomy ); $object_terms = get_object_term_cache( $object_id, $taxonomy );
if ( false === $object_terms ) { if ( false === $object_terms ) {
$object_terms = wp_get_object_terms( $object_id, $taxonomy, array( 'update_term_meta_cache' => false ) ); $object_terms = wp_get_object_terms( $object_id, $taxonomy, array( 'update_term_meta_cache' => false ) );
if ( is_wp_error( $object_terms ) ) {
return $object_terms;
}
wp_cache_set( $object_id, wp_list_pluck( $object_terms, 'term_id' ), "{$taxonomy}_relationships" ); wp_cache_set( $object_id, wp_list_pluck( $object_terms, 'term_id' ), "{$taxonomy}_relationships" );
} }

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.6.1-alpha-38339'; $wp_version = '4.6.1-alpha-38346';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.