WordPress.org

Make WordPress Core

Opened 7 months ago

Closed 5 months ago

#46438 closed enhancement (fixed)

Change all instances of date() to gmdate()

Reported by: Rarst Owned by: SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version:
Component: Date/Time Keywords: has-patch
Focuses: Cc:
PR Number:

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 7 months ago.
46438.2.diff (87.8 KB) - added by nielsdeblaauw 7 months ago.
46438.3.diff (87.2 KB) - added by nielsdeblaauw 7 months ago.
46438_4.patch (88.4 KB) - added by Rarst 5 months ago.

Download all attachments as: .zip

Change History (10)

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


7 months ago

@nielsdeblaauw
7 months ago

#3 @Rarst
7 months 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 months ago

#4 @Rarst
5 months 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 months ago

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

#6 @SergeyBiryukov
5 months 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.

Note: See TracTickets for help on using tickets.