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. Built from https://develop.svn.wordpress.org/trunk@58923 git-svn-id: http://core.svn.wordpress.org/trunk@58319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2531f22a15
commit
78a0c7a5b3
|
@ -73,7 +73,7 @@ function mysql2date( $format, $date, $translate = true ) {
|
||||||
function current_time( $type, $gmt = 0 ) {
|
function current_time( $type, $gmt = 0 ) {
|
||||||
// Don't use non-GMT timestamp, unless you know the difference and really need to.
|
// Don't use non-GMT timestamp, unless you know the difference and really need to.
|
||||||
if ( 'timestamp' === $type || 'U' === $type ) {
|
if ( 'timestamp' === $type || 'U' === $type ) {
|
||||||
return $gmt ? time() : time() + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
|
return $gmt ? time() : time() + (int) ( (float) get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'mysql' === $type ) {
|
if ( 'mysql' === $type ) {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.7-alpha-58922';
|
$wp_version = '6.7-alpha-58923';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue