[wp-trac] [WordPress Trac] #38277: the_tags() will fatal error if get_the_tag_list() fails

WordPress Trac noreply at wordpress.org
Mon Oct 10 19:37:44 UTC 2016


#38277: the_tags() will fatal error if get_the_tag_list() fails
--------------------------+-----------------------------
 Reporter:  claudiulodro  |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:  4.6.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 On failure, get_the_tag_list (used by the_tags() ) will return a WP_Error
 object. the_tags() has no checking for this WP_Error object, so it will
 throw a fatal error when it tries to echo the WP_Error object that
 get_the_tag_list returned. My proposed solution is as follows:
 {{{#!php
 <?php
 function the_tags( $before = null, $sep = ', ', $after = '' ) {
         if ( null === $before )
                 $before = __( 'Tags: ' );

         $tag_list = get_the_tag_list( $before, $sep, $after );
         if( is_wp_error( $tag_list ) ) {
                 return;
         }

         echo $tag_list;
 }
 }}}

 I will attach a formal patch for this soon as I have a chance.

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


More information about the wp-trac mailing list