Page MenuHomePhabricator

Block expiry time displayed in the logs is based on the Unix epoch instead of current time (e.g. an expiry of "10 september" displays as "00:00, 10 September 1970")
Closed, ResolvedPublic

Description

How to reproduce:

Type "10 september" into the expiry box on Special:Block (if this date has passed, increase it)

Go back to the log entry for that block, and you see a year of 1970.

Expected result: Year should be 2013

09:17, 8 September 2013 Legoktm (talk | contribs | block) blocked Legosock (talk | contribs) (autoblock disabled) with an expiry time of 00:00, 10 September 1970 (testing a bug) (unblock | change block)

Note that this doesn't affect the actual block, which uses the intended expiry. This can be confirmed by looking at [[Special:BlockList]] (https://en.wikipedia.org/wiki/Special:BlockList?wpTarget=Legosock&limit=50) or via the API: https://en.wikipedia.org/w/api.php?action=query&list=logevents&letype=block&lelimit=100&format=jsonfm&letitle=User:Legosock

Details

Reference
bz53907

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 22 2014, 2:00 AM
bzimport set Reference to bz53907.
bzimport added a subscriber: Unknown Object (MLST).
Legoktm created this task.Sep 8 2013, 9:23 AM
Tgr renamed this task from Entering "10 september" displays a block expiry time of "00:00, 10 September 1970" to Block expiry time displayed in the logs is based on the Unix epoch instead of current time (e.g. an expiry of "10 september" displays as "00:00, 10 September 1970").Nov 4 2016, 9:37 PM
Tgr updated the task description. (Show Details)
Tgr set Security to None.
Tgr added subscribers: matmarex, binbot, Aklapper, Tgr.

@matmarex said on wikitech-l:

The problem seems to be in the block log formatter. BlockLogFormatter::getMessageParameters() calls Language::translateBlockExpiry() to format the string "2 months" (and translate it). That in turn uses strtotime() to parse this value, and does not specify the $now parameter correctly, so January 1, 1970 is assumed. And two months, counting from January 1, 1970, is 59 days. Two months counting from today, when you made the block, is 61 days, and this correctly appears everywhere else (the block expires 2017-01-04T06:30:06Z).
BlockLogFormatter::getMessageParameters() and Language::translateBlockExpiry() should probably be fixed to use the date when the block was made for the $now parameter of strtotime().

Snaevar added a subscriber: Snaevar.Nov 5 2016, 1:11 AM
MZMcBride added a subscriber: MZMcBride.
Restricted Application added a subscriber: TerraCodes. · View Herald TranscriptNov 5 2016, 6:55 AM

I don't think fixing this issue should be terribly difficult, so I'm adding the good first bug tag. Adding some test coverage would really help here, I imagine.

matmarex claimed this task.Jan 18 2017, 1:06 PM

No takers? Okay.

Change 332764 had a related patch set uploaded (by Bartosz Dziewoński):
BlockLogFormatter: Durations are relative to block's timestamp, not Unix epoch

https://gerrit.wikimedia.org/r/332764

Florian closed this task as Resolved.Jan 21 2017, 6:44 PM

Change 332764 merged by jenkins-bot:
BlockLogFormatter: Durations are relative to block's timestamp, not Unix epoch

https://gerrit.wikimedia.org/r/332764

Snaevar removed a subscriber: Snaevar.Mar 10 2017, 6:37 PM