ReverseChronologicalPager: Fix timezone confusion
authorBartosz Dziewoński <matma.rex@gmail.com>
Mon, 23 Jul 2018 21:34:40 +0000 (23:34 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Thu, 26 Jul 2018 20:11:52 +0000 (22:11 +0200)
commit249e0c06e4bfc4ed4d0ffc3c768dfe4b60f9efa5
tree4fc8d6d2fc9bfa6be6b63be84501e10fe9493ece
parent9f48da6a2ef03b38bae83ea7f2902855f9294b13
ReverseChronologicalPager: Fix timezone confusion

(This change is best tested with Special:Log before changes from
38756eae4, since it seems the $mDay/$mMonth/$mYear values are not
directly used anywhere in core after that.)

The setTimezone() call did not actually change the offset used for
database lookup, because getTimestamp() returns a Unix timestamp,
which by definition does not include timezone information.

It did change the offset used for year/month/day fields in the
interface, but it changed it in the wrong direction: instead of
assuming the date is in local timezone and converting to UTC, it
assumed the date is in UTC and converted it to local timezone.

We don't actually want to do anything with timezones here. For better
or worse, the date selectors for pagers have always used UTC dates.
The timezone code was only introduced relatively recently in 53fa809a.

What we really want for the interface is to display the previous
date, relative to the database offset. The interface asks the user
to select the month/date up to which to display things (such as
"May 2018 (and earlier)"), but the database queries use strict
comparison (such as `log_timestamp < '20180601000000'`), so the
database offset is calculated to the next date after selected one.

The incorrect timezone calculation accidentally did so, but only if
the wiki timezone had a negative offset relative to the UTC. If the
wiki was using UTC or a timezone with positive offset, the correction
was not applied, causing the selected date in the interface to move
one day forward from the date that was set.

Bug: T171110
Change-Id: I8c2cd398d7c7ac68a8f46ee94cb9e7c6beed5694
includes/pager/ReverseChronologicalPager.php