Make WordPress Core


Ignore:
Timestamp:
08/22/2024 11:25:17 PM (7 weeks ago)
Author:
peterwilsoncc
Message:

Date/Time: Prevent type errors in current_time().

Prevents a potential type error when calling current_time( 'timestamp' ) by casting get_option( 'gmt_offset' ) to a float prior to performing calculations with the value.

This mainly accounts for incorrect storage of values, such as an empty string or city name.

Follow up to [45856], [55054], [55598].

Props hellofromtonya, peterwilsoncc, rarst, costdev, Nick_theGeek, SergeyBiryukov, johnbillion, desrosj, reputeinfosystems, audrasjb, oglekler.
Fixes #57035.

File:
1 edited

Legend:

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

    r58849 r58923  
    7474    // Don't use non-GMT timestamp, unless you know the difference and really need to.
    7575    if ( 'timestamp' === $type || 'U' === $type ) {
    76         return $gmt ? time() : time() + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
     76        return $gmt ? time() : time() + (int) ( (float) get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
    7777    }
    7878
Note: See TracChangeset for help on using the changeset viewer.