WordPress.org

Make WordPress Core

Ticket #28636: localized-time-default-current-invalid-input.patch

File localized-time-default-current-invalid-input.patch, 1.1 KB (added by Rarst, 15 months ago)
  • src/wp-includes/functions.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    163163 * @return string The date, translated if locale specifies it.
    164164 */
    165165function date_i18n( $format, $timestamp_with_offset = false, $gmt = false ) {
     166
     167        $timestamp = $timestamp_with_offset;
     168
    166169        // If timestamp is omitted it should be current time (summed with offset, unless `$gmt` is true).
    167         $timestamp = $timestamp_with_offset ? $timestamp_with_offset : current_time( 'timestamp', $gmt );
     170        if ( ! is_numeric( $timestamp ) ) {
     171                $timestamp = current_time( 'timestamp', $gmt );
     172        }
    168173
    169174        /*
    170175         * This is a legacy implementation quirk that the returned timestamp is also with offset.
     
    223228function wp_date( $format, $timestamp = null, $timezone = null ) {
    224229        global $wp_locale;
    225230
    226         if ( ! $timestamp ) {
     231        if ( ! is_numeric( $timestamp ) ) {
    227232                $timestamp = time();
    228233        }
    229234