Ticket #58986: 58986.diff
File 58986.diff, 8.7 KB (added by , 16 months ago) |
---|
-
src/wp-admin/options-general.php
diff --git src/wp-admin/options-general.php src/wp-admin/options-general.php index c79851badc..fe0f868dd8 100644
if ( ! empty( $languages ) || ! empty( $translations ) ) { 230 230 ?> 231 231 <tr> 232 232 <?php 233 $current_offset = get_option( 'gmt_offset');233 $current_offset = current_gmt_offset(); 234 234 $tzstring = get_option( 'timezone_string' ); 235 235 236 236 $check_zone_info = true; -
src/wp-admin/update-core.php
diff --git src/wp-admin/update-core.php src/wp-admin/update-core.php index 8949f39e33..719b89c290 100644
if ( 'upgrade-core' === $action ) { 1079 1079 $current = get_site_transient( 'update_core' ); 1080 1080 1081 1081 if ( $current && isset( $current->last_checked ) ) { 1082 $last_update_check = $current->last_checked + get_option( 'gmt_offset') * HOUR_IN_SECONDS;1082 $last_update_check = $current->last_checked + current_gmt_offset() * HOUR_IN_SECONDS; 1083 1083 } 1084 1084 1085 1085 echo '<h2 class="wp-current-version">'; -
src/wp-includes/bookmark-template.php
diff --git src/wp-includes/bookmark-template.php src/wp-includes/bookmark-template.php index d9bca2bbd7..9696d2b49d 100644
function _walk_bookmarks( $bookmarks, $args = '' ) { 90 90 __( 'Last updated: %s' ), 91 91 gmdate( 92 92 get_option( 'links_updated_date_format' ), 93 $bookmark->link_updated_f + ( get_option( 'gmt_offset') * HOUR_IN_SECONDS )93 $bookmark->link_updated_f + ( current_gmt_offset() * HOUR_IN_SECONDS ) 94 94 ) 95 95 ); 96 96 $title .= ')'; -
src/wp-includes/customize/class-wp-customize-date-time-control.php
diff --git src/wp-includes/customize/class-wp-customize-date-time-control.php src/wp-includes/customize/class-wp-customize-date-time-control.php index 1b445af37f..5c12b3a4f0 100644
class WP_Customize_Date_Time_Control extends WP_Customize_Control { 280 280 $timezone_info['description'] = ''; 281 281 } 282 282 } else { 283 $formatted_gmt_offset = $this->format_gmt_offset( (int) get_option( 'gmt_offset', 0) );283 $formatted_gmt_offset = $this->format_gmt_offset( current_gmt_offset() ); 284 284 285 285 $timezone_info['description'] = sprintf( 286 286 /* translators: 1: UTC abbreviation and offset, 2: UTC offset. */ -
src/wp-includes/deprecated.php
diff --git src/wp-includes/deprecated.php src/wp-includes/deprecated.php index 72bf98d832..df44ef48bb 100644
function get_links($category = -1, $before = '', $after = '<br />', $between = ' 981 981 982 982 if ( $show_updated ) 983 983 if ( !str_starts_with($row->link_updated_f, '00') ) 984 $title .= ' ('.__('Last updated') . ' ' . gmdate(get_option('links_updated_date_format'), $row->link_updated_f + ( get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')';984 $title .= ' ('.__('Last updated') . ' ' . gmdate(get_option('links_updated_date_format'), $row->link_updated_f + (current_gmt_offset() * HOUR_IN_SECONDS)) . ')'; 985 985 986 986 if ( '' != $title ) 987 987 $title = ' title="' . $title . '"'; -
src/wp-includes/functions.php
diff --git src/wp-includes/functions.php src/wp-includes/functions.php index 16a32dd7bf..0fbd93e201 100644
function mysql2date( $format, $date, $translate = true ) { 73 73 function current_time( $type, $gmt = 0 ) { 74 74 // Don't use non-GMT timestamp, unless you know the difference and really need to. 75 75 if ( 'timestamp' === $type || 'U' === $type ) { 76 return $gmt ? time() : time() + (int) ( get_option( 'gmt_offset') * HOUR_IN_SECONDS );76 return $gmt ? time() : time() + (int) ( current_gmt_offset() * HOUR_IN_SECONDS ); 77 77 } 78 78 79 79 if ( 'mysql' === $type ) { … … function current_datetime() { 97 97 return new DateTimeImmutable( 'now', wp_timezone() ); 98 98 } 99 99 100 /** 101 * Retrieves the current GMT offset set for the site. 102 * 103 * - Default to 0 if the option is not set or invalid 104 * 105 * @since 6.4.0 106 * 107 * @return float 108 */ 109 function current_gmt_offset() { 110 return (float) get_option( 'gmt_offset', 0 ); 111 } 112 100 113 /** 101 114 * Retrieves the timezone of the site as a string. 102 115 * … … function wp_timezone_string() { 123 136 return $timezone_string; 124 137 } 125 138 126 $offset = (float) get_option( 'gmt_offset');139 $offset = current_gmt_offset(); 127 140 $hours = (int) $offset; 128 141 $minutes = ( $offset - $hours ); 129 142 -
src/wp-includes/rest-api/class-wp-rest-server.php
diff --git src/wp-includes/rest-api/class-wp-rest-server.php src/wp-includes/rest-api/class-wp-rest-server.php index 9df4556ada..41ae6bb60c 100644
class WP_REST_Server { 1265 1265 'description' => get_option( 'blogdescription' ), 1266 1266 'url' => get_option( 'siteurl' ), 1267 1267 'home' => home_url(), 1268 'gmt_offset' => get_option( 'gmt_offset'),1268 'gmt_offset' => current_gmt_offset(), 1269 1269 'timezone_string' => get_option( 'timezone_string' ), 1270 1270 'namespaces' => array_keys( $this->namespaces ), 1271 1271 'authentication' => array(), -
src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index 356c321129..ab34a4c18b 100644
class WP_REST_Posts_Controller extends WP_REST_Controller { 1802 1802 * with the site's timezone offset applied. 1803 1803 */ 1804 1804 if ( '0000-00-00 00:00:00' === $post->post_modified_gmt ) { 1805 $post_modified_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $post->post_modified ) - ( get_option( 'gmt_offset') * HOUR_IN_SECONDS ) );1805 $post_modified_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $post->post_modified ) - ( current_gmt_offset() * HOUR_IN_SECONDS ) ); 1806 1806 } else { 1807 1807 $post_modified_gmt = $post->post_modified_gmt; 1808 1808 } -
src/wp-includes/script-loader.php
diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php index 205cedda72..c32a60067d 100644
function wp_default_packages_inline_scripts( $scripts ) { 444 444 'datetimeAbbreviated' => __( 'M j, Y g:i a' ), 445 445 ), 446 446 'timezone' => array( 447 'offset' => (float) get_option( 'gmt_offset', 0),447 'offset' => current_gmt_offset(), 448 448 'string' => $timezone_string, 449 449 'abbr' => $timezone_abbr, 450 450 ), -
src/wp-mail.php
diff --git src/wp-mail.php src/wp-mail.php index 1dd1e570d1..7f2921269e 100644
if ( $last_checked ) { 44 44 45 45 set_transient( 'mailserver_last_checked', true, WP_MAIL_INTERVAL ); 46 46 47 $time_difference = get_option( 'gmt_offset') * HOUR_IN_SECONDS;47 $time_difference = current_gmt_offset() * HOUR_IN_SECONDS; 48 48 49 49 $phone_delim = '::'; 50 50 -
new file tests/phpunit/tests/date/currentGmtOffset.php
diff --git tests/phpunit/tests/date/currentGmtOffset.php tests/phpunit/tests/date/currentGmtOffset.php new file mode 100644 index 0000000000..8a0805c1fd
- + 1 <?php 2 3 /** 4 * @group date 5 * @group datetime 6 * @covers ::current_gmt_offset() 7 */ 8 class Tests_Date_CurrentGmtOffset extends WP_UnitTestCase { 9 10 /** 11 * Cleans up. 12 */ 13 public function tear_down() { 14 // Reset changed options to their default value. 15 update_option( 'gmt_offset', 0 ); 16 17 parent::tear_down(); 18 } 19 20 /** 21 * @ticket 58986 22 */ 23 public function test_current_gmt_offset_empty_is_default() { 24 delete_option( 'gmt_offset' ); 25 26 $this->assertIsFloat( current_gmt_offset(), 'Missing current GMT offset is default of 0'); 27 } 28 29 /** 30 * @ticket 58986 31 */ 32 public function test_current_gmt_offset_invalid_boolean_true() { 33 update_option( 'gmt_offset', true ); 34 35 $this->assertEquals( 0, current_gmt_offset(), 'Invalid current GMT offset of boolean true is 0'); 36 } 37 38 /** 39 * @ticket 58986 40 */ 41 public function test_current_gmt_offset_invalid_string() { 42 update_option( 'gmt_offset', 'NinePointFive' ); 43 44 $this->assertEquals( 0, current_gmt_offset(), 'Invalid current GMT offset of non-numeric text is 0'); 45 } 46 47 /** 48 * @ticket 58986 49 */ 50 public function test_current_gmt_offset_is_float() { 51 update_option( 'gmt_offset', 9.5 ); 52 53 $this->assertIsFloat( current_gmt_offset(), 'Current GMT offset is a float'); 54 } 55 } -
tests/qunit/fixtures/wp-api-generated.js
diff --git tests/qunit/fixtures/wp-api-generated.js tests/qunit/fixtures/wp-api-generated.js index 27aa52edcc..9f58d5e239 100644
mockedApiResponse.Schema = { 10 10 "description": "", 11 11 "url": "http://example.org", 12 12 "home": "http://example.org", 13 "gmt_offset": "0",13 "gmt_offset": 0, 14 14 "timezone_string": "", 15 15 "namespaces": [ 16 16 "oembed/1.0",