WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#38277 closed defect (bug) (duplicate)

the_tags() will fatal error if get_the_tag_list() fails

Reported by: claudiulodro Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords:
Focuses: Cc:

Description

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
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.

Change History (1)

#1 @ocean90
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version 4.6.1 deleted

Hello @claudiulodro, welcome to Trac!

Thanks for your report, we're already tracking this issue in #37291.

Note: See TracTickets for help on using tickets.