HomePhabricator

Honor timezones in input, and correct some odd accepted values
7ce5fa7fb523Unpublished

Unpublished Commit · Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

Honor timezones in input, and correct some odd accepted values

Formats TS_POSTGRES, TS_RFC2822, and TS_RFC850 can include a non-UTC
timezone, which the code was mostly ignoring. We should honor the
timezones in these inputs.

"asctime" format was being allowed to have a timezone, even though POSIX
doesn't say it does. This mostly didn't matter though, because it too
was mostly ignored.

Several of the input formats had regex bugs that allowed times like
"2019-05-22T12:00:00.....1257" or "Wed, 22 May 2019 12:00:00 A potato"
to be accepted. We should avoid accepting things like that.

TS_RFC2822 was not handling FWS or two- and three-digit years properly,
and was rejecting the "UT" timezone.

TS_UNIX_MICRO isn't working right with timestamps before the epoch.

Also, it looks like at some point the regex for TS_ORACLE was changed
but fixups for the old format weren't removed.

This refactor fixes all of those, by using regex capturing groups to
collect date components directly (including any timezones) and using
DateTime::createFromFormat() to parse exactly the collected components
instead of letting PHP try to interpret a freeform string, and by
tightening up some of the regexes.

Bug: T224197
Bug: T224198
Bug: T224199
Bug: T224202
Change-Id: Ia4f41d8719d9367eb9e75077f5a6de2e850d2a67

Details

Provenance
AnomieAuthored on May 22 2019, 9:02 PM
Parents
R1985:74fa3db96b56: build: Updating mediawiki/mediawiki-codesniffer to 24.0.0
Branches
Unknown
Tags
Unknown
References
refs/changes/71/512071/2
ChangeId
Ia4f41d8719d9367eb9e75077f5a6de2e850d2a67