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/tests/phpunit/tests/date/getPostTime.php

    r48911 r48912  
    1111     * @ticket 28310
    1212     */
    13     public function test_get_post_time_with_id_returns_correct_time() {
     13    public function test_get_post_time_returns_correct_time_with_post_id() {
    1414        $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
     15
    1516        $this->assertEquals( '16:35:00', get_post_time( 'H:i:s', false, $post_id ) );
    1617    }
     
    2930     * @ticket 28310
    3031     */
    31     public function test_get_post_modified_time_with_id_returns_correct_time() {
     32    public function test_get_post_modified_time_returns_correct_time_with_post_id() {
    3233        $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
     34
    3335        $this->assertEquals( '16:35:00', get_post_modified_time( 'H:i:s', false, $post_id ) );
    3436    }
Note: See TracChangeset for help on using the changeset viewer.