Make WordPress Core

Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#46438 closed enhancement (fixed)

Change all instances of date() to gmdate()

Reported by: rarst's profile Rarst Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version:
Component: Date/Time Keywords: has-patch
Focuses: Cc:

Description

Use of date() in core depends on PHP timezone set to UTC (performed by the core boot) and not changed by third party code (which cannot be guaranteed).

All instances of date() in core should be replaced with gmdate(), which is functionally equivalent but is not affected by PHP time zone setting (it's always UTC which is the exact behavior we need).

One of the steps for eliminating dependency on UTC timezone setting, see #44491

Attachments (4)

46438.diff (101.2 KB) - added by nielsdeblaauw 6 years ago.
46438.2.diff (87.8 KB) - added by nielsdeblaauw 6 years ago.
46438.3.diff (87.2 KB) - added by nielsdeblaauw 6 years ago.
46438_4.patch (88.4 KB) - added by Rarst 5 years ago.

Download all attachments as: .zip

Change History (11)

This ticket was mentioned in Slack in #core-datetime by rarst. View the logs.


6 years ago

@nielsdeblaauw
6 years ago

#3 @Rarst
6 years ago

I spotted that couple of changes are in upstream-ish libs (PHPMailer, SimplePie) so we might want to skip those. Otherwise looks good to me.

@Rarst
5 years ago

#4 @Rarst
5 years ago

  • Keywords has-patch added; needs-patch removed

I have rebased patch on latest master, threw out some white space changes that sneaked in, and ommitted couple changes in semi-external pieces for now.

#5 @SergeyBiryukov
5 years ago

  • Milestone changed from Awaiting Review to 5.3
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#6 @SergeyBiryukov
5 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 45424:

Date/Time: Replace all instances of date() with gmdate().

Use of date() in core depends on PHP timezone set to UTC and not changed by third party code (which cannot be guaranteed).

gmdate() is functionally equivalent, but is not affected by PHP timezone setting: it's always UTC, which is the exact behavior the core needs.

Props nielsdeblaauw, Rarst.
Fixes #46438. See #44491.

#7 @SergeyBiryukov
5 years ago

In 47080:

Tests: Replace date() with gmdate() in WP_Test_REST_Posts_Controller tests.

Follow-up to [45424], [46252].

See #46438, #44491, #39953.

Note: See TracTickets for help on using tickets.