Date/Time, PHP Compat: Prevent type errors using GMT offset option.

Prevents a potential type errors when making use of the `gmt_offset` option by casting the value 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 [58923].

Props chaion07, hellofromtonya, kirasong, mhshohel, mukesh27, nicolefurlan, nihar007, nurielmeni, oglekler, peterwilsoncc, prionkor, rajinsharwar, rarst, rleeson, sabernhardt, SergeyBiryukov, swissspidy, toastercookie, verygoode.
Fixes #56358, #58986, #60629.

Built from https://develop.svn.wordpress.org/trunk@59064


git-svn-id: http://core.svn.wordpress.org/trunk@58460 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2024-09-18 22:37:15 +00:00
parent abe6e87596
commit 2cc6bb80ef
5 changed files with 5 additions and 5 deletions

View File

@ -1096,7 +1096,7 @@ if ( 'upgrade-core' === $action ) {
$current = get_site_transient( 'update_core' ); $current = get_site_transient( 'update_core' );
if ( $current && isset( $current->last_checked ) ) { if ( $current && isset( $current->last_checked ) ) {
$last_update_check = $current->last_checked + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS; $last_update_check = $current->last_checked + (int) ( (float) get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
} }
echo '<h2 class="wp-current-version">'; echo '<h2 class="wp-current-version">';

View File

@ -90,7 +90,7 @@ function _walk_bookmarks( $bookmarks, $args = '' ) {
__( 'Last updated: %s' ), __( 'Last updated: %s' ),
gmdate( gmdate(
get_option( 'links_updated_date_format' ), get_option( 'links_updated_date_format' ),
$bookmark->link_updated_f + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) $bookmark->link_updated_f + (int) ( (float) get_option( 'gmt_offset' ) * HOUR_IN_SECONDS )
) )
); );
$title .= ')'; $title .= ')';

View File

@ -1816,7 +1816,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
* with the site's timezone offset applied. * with the site's timezone offset applied.
*/ */
if ( '0000-00-00 00:00:00' === $post->post_modified_gmt ) { if ( '0000-00-00 00:00:00' === $post->post_modified_gmt ) {
$post_modified_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $post->post_modified ) - ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ); $post_modified_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $post->post_modified ) - (int) ( (float) get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) );
} else { } else {
$post_modified_gmt = $post->post_modified_gmt; $post_modified_gmt = $post->post_modified_gmt;
} }

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.7-alpha-59063'; $wp_version = '6.7-alpha-59064';
/** /**
* 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.

View File

@ -44,7 +44,7 @@ if ( $last_checked ) {
set_transient( 'mailserver_last_checked', true, WP_MAIL_INTERVAL ); set_transient( 'mailserver_last_checked', true, WP_MAIL_INTERVAL );
$time_difference = get_option( 'gmt_offset' ) * HOUR_IN_SECONDS; $time_difference = (int) ( (float) get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
$phone_delim = '::'; $phone_delim = '::';