From 55c34595d013ed02c1126a05ede66c1943ab72b3 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Wed, 11 Jan 2023 23:18:12 +0000 Subject: [PATCH] Date/Time: Prevent errors in `current_time()` when using timestamp and no value for `gmt_offset`. This changeset moves typecasting to affect the `get_option` value, which ensures that when math is done it does not generate any error. In PHP 7.4 and earlier the previous implementation was dismissed as a warning, but in PHP 8+ it would have throw a fatal error. Follow-up to [45856]. Props Nick_theGeek, SergeyBiryukov, johnbillion. Fixes #57035. git-svn-id: https://develop.svn.wordpress.org/trunk@55054 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 620ff23ed7..5d1f52e762 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -72,7 +72,7 @@ function mysql2date( $format, $date, $translate = true ) { function current_time( $type, $gmt = 0 ) { // Don't use non-GMT timestamp, unless you know the difference and really need to. if ( 'timestamp' === $type || 'U' === $type ) { - return $gmt ? time() : time() + (int) ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); + return $gmt ? time() : time() + ( (int) get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); } if ( 'mysql' === $type ) {