[wp-trac] [WordPress Trac] #38940: current_time() expects that date_default_timezone_set is never used

WordPress Trac noreply at wordpress.org
Fri Nov 25 14:13:50 UTC 2016


#38940: current_time() expects that date_default_timezone_set is never used
------------------------------------------------+--------------------------
 Reporter:  marco.marsala                       |       Owner:
     Type:  defect (bug)                        |      Status:  new
 Priority:  normal                              |   Milestone:  Awaiting
Component:  Date/Time                           |  Review
 Severity:  normal                              |     Version:  4.6.1
 Keywords:  has-patch dev-feedback 2nd-opinion  |  Resolution:
                                                |     Focuses:
------------------------------------------------+--------------------------
Changes (by jdgrimes):

 * keywords:  has-patch => has-patch dev-feedback 2nd-opinion


Comment:

 I'd say it is more of a documentation problem than a code problem. The
 code has been this way for a long time, and I don't know if there have
 been any complaints about bugs arising from code outside WordPress core
 calling `date_default_timezone_set()`. It would affect a lot of time-
 related stuff in WordPress, since `date()` is used many other places where
 `gmdate()` would need to be used instead. Ensuring that we always use
 `gmdate()` when getting UTC time would be an extra precaution, but it
 wouldn't immediately make it OK for code to call
 `date_default_timezone_set()`, because a lot of plugins would still be
 assuming `date()` to be UTC. So, for backward-compatibility reasons, I
 doubt that we should change the code. Not unless there actually is a
 significant specific use-case for making WordPress core resilient against
 calls to `date_default_timezone_set()`.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38940#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list