Skip to content

Commit

Permalink
意外重置时区设置,导致评论时间显示为负数。
Browse files Browse the repository at this point in the history
当时区设置为不同格式,如数字:+8,或者时区名:Asia/Shanghai 时,
PHP 脚本得到的时区可能不一致,被意外重置!
  • Loading branch information
leiww committed Jan 14, 2010
1 parent e19895b commit fd6a5d4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions .topdeps
@@ -0,0 +1 @@
master
7 changes: 7 additions & 0 deletions .topmsg
@@ -0,0 +1,7 @@
From: leiww <leiww@bj.ossxp.com>
Subject: [PATCH] t/fix_timezone_reset_bug

当时区设置为不同格式,如数字:+8,或者时区名:Asia/Shanghai 时,PHP 脚本得到的时区可能不一致,被意外重置!
例如会导致:意外重置时区设置,导致评论时间显示为负数。

Signed-off-by: leiww <leiww@bj.ossxp.com>
5 changes: 4 additions & 1 deletion wp-includes/functions.php
Expand Up @@ -3321,7 +3321,10 @@ function wp_timezone_override_offset() {
return false;
}

@date_default_timezone_set( $timezone_string );
// Warning: Do not reset timezone here, timezone offset can be provided in eithor
// gmt_offset, or timezone_string. Reset here will cause trouble.
// -- ossxp.com
// @date_default_timezone_set( $timezone_string );
$timezone_object = timezone_open( $timezone_string );
$datetime_object = date_create();
if ( false === $timezone_object || false === $datetime_object ) {
Expand Down

0 comments on commit fd6a5d4

Please sign in to comment.