[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:37:00 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:
------------------------------------------------+--------------------------
Comment (by jdgrimes):
Replying to [comment:5 marco.marsala]:
> I didn't suggest to change `date()` into `gmdate()`.
>
> The proposed patch would affect only the b`current_time()` and has no
side effect on `date()` function outside `current_time()` calls, look at
the code above.
I understand that, but if some code outside of WordPress core uses
`date_default_timezone_set()`, it will affect every call to `date()` in
WordPress (and plugins), not just the `current_time()` function.
`current_time()` is not used everywhere that WordPress retrieves the
current date/time, so other places in the code will still be affected by
the changed timezone, even though they are expected to be getting the UTC
time. They would need to be updated to use `current_time()` or `gmdate()`
in that case.
In fact, you could avoid changing the timezone in your patch fore
`current_time()`, you could just update it to use `gmdate()` instead of
`date()`, I think.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38940#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list