Make WordPress Core


Ignore:
Timestamp:
08/31/2020 03:56:41 PM (4 years ago)
Author:
SergeyBiryukov
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.
Fixes #51184.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment-template.php

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