SpecialRecentchanges: Handle ?days= parameter more sanely
authorRoan Kattouw <roan.kattouw@gmail.com>
Mon, 24 Jul 2017 23:38:59 +0000 (16:38 -0700)
committerRoan Kattouw <roan.kattouw@gmail.com>
Mon, 24 Jul 2017 23:49:05 +0000 (16:49 -0700)
commit9db2cc13e0c023202845616d181cc84cd5e2d7d8
tree82921fdccb16652853e8bda6eabb8547654b773b
parent1a81ba9bcb801de0be82fbd44332dada53800879
SpecialRecentchanges: Handle ?days= parameter more sanely

Allow fractional values (e.g ?days=0.25). Previously, fractional values
were rounded down (truncated) to integers.

When computing the cutoff timestamp, don't round down to midnight UTC.
This caused a strange phenomenon where ?days=1 would display between
24 and 48 hours' worth of changes depending on when you used it:
if the current time was 2017-07-24 23:59 UTC, the cutoff would be
set at 2017-07-23 00:00 UTC so you would see almost 48 hours' worth,
but if you refreshed two minutes later, the cutoff would be set at
2017-07-24 00:00 UTC and you should see just over 24 hours' worth.
In addition to this strangeness, it also made fractional values
somewhat meaningless and made a feature like "show only the last 3 hours"
impossible to implement.

Bug: T162784
Change-Id: I75b71324e29a4da09939c4b00feeb4cb556f797c
includes/specials/SpecialRecentchanges.php
tests/phpunit/includes/specials/SpecialRecentchangesTest.php