Make WordPress Core


Ignore:
Timestamp:
08/31/2020 06:56:22 PM (4 years ago)
Author:
desrosj
Message:

Date/Time: Make sure get_the_date() and related functions return correct time if the format was specified as false.

Technically, the $format argument should always be a string, but passing false used to work before [47808], so this restores backward compatibility.

The list of affected functions:

  • get_the_date()
  • get_the_time()
  • get_comment_date()
  • get_comment_time()

Props wittich, Rarst, akabarikalpesh, SergeyBiryukov.
Merges [48912] to the 5.5 branch.
Fixes #51184.

Location:
branches/5.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.5

  • branches/5.5/src/wp-includes/comment-template.php

    r48597 r48921  
    553553    $comment = get_comment( $comment_ID );
    554554
    555     if ( '' === $format ) {
    556         $date = mysql2date( get_option( 'date_format' ), $comment->comment_date );
    557     } else {
    558         $date = mysql2date( $format, $comment->comment_date );
    559     }
     555    if ( ! is_string( $format ) || '' === $format ) {
     556        $format = get_option( 'date_format' );
     557    }
     558
     559    $date = mysql2date( $format, $comment->comment_date );
    560560
    561561    /**
     
    10471047    $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
    10481048
    1049     if ( '' === $format ) {
    1050         $date = mysql2date( get_option( 'time_format' ), $comment_date, $translate );
    1051     } else {
    1052         $date = mysql2date( $format, $comment_date, $translate );
    1053     }
     1049    if ( ! is_string( $format ) || '' === $format ) {
     1050        $format = get_option( 'time_format' );
     1051    }
     1052
     1053    $date = mysql2date( $format, $comment_date, $translate );
    10541054
    10551055    /**
Note: See TracChangeset for help on using the changeset viewer.