[wp-trac] [WordPress Trac] #35265: get_the_terms return on non-existing term

WordPress Trac noreply at wordpress.org
Wed Dec 30 16:36:50 UTC 2015


#35265: get_the_terms return on non-existing term
--------------------------+-----------------------------
 Reporter:  tivnet        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  4.4
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 {{{#!php
 <?php
 function get_the_terms( $post, $taxonomy ) {
         if ( ! $post = get_post( $post ) )
                 return false;

         $terms = get_object_term_cache( $post->ID, $taxonomy );
         if ( false === $terms ) {
                 $terms = wp_get_object_terms( $post->ID, $taxonomy );

 // ---------- PROPOSED (should we return WP_Error or false here?)

                 if ( is_wp_error( $terms ) ) {
                         return $terms;
                 }

 // ----------

                 $to_cache = array();
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35265>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list