Page MenuHomePhabricator

Relative timestamps do not update while the page is open
Open, Needs TriagePublic

Description

  1. Open a talk page with a topic container where the latest comment is X minutes ago
  2. Leave the page open for at least 1 minute
  3. Observe the "X minutes ago" message has not changed to "X+1 minutes ago"

Flow has some JS to update these timestamps every minute. We also update timestamps every minute when inserting signatures in article editing mode of VE. Something like what Flow does would probably be helpful,.

This wouldn't however fix the issues that the "latest comment" may not still be the latest comment (someone else has posted), so one could argue that the page should just represent the truth at the time it was rendered.

Event Timeline

I wonder if this'd be better addressed as some sort of mediawiki-wide fix? Anything with e.g. <span class="mw-relative-time" data-ts="123443432"> would get updated by some site-wide JS, extensions and pages wouldn't need to independently implement it, and users wouldn't have to remember which pages have this behavior and which don't...

A core solution might be helpful, I don't know where getHumanTimestamp is used. I think there is an existing issue in that the JS library used is not identical to the PHP library.

Anything with e.g. <span class="mw-relative-time" data-ts="123443432"> would get updated by some site-wide JS

As far as I remember, moment.js is quite a heavy library, so automagically including it may have unwanted performance consequences (especially as <span class="mw-relative-time" data-ts="123443432"> can be added by unprivileged users to the parser output).

A core solution might be helpful, I don't know where getHumanTimestamp is used. I think there is an existing issue in that the JS library used is not identical to the PHP library.

getHumanTimestamp currently outputs plain text, and this may be assumed by callers (e.g. ad5a7f50 includes it in an API result, and the consumer added in f9aac368 escapes it before adding to the page). If we want it to output machine-readable data for moment.js, it should be a new method or an optional parameter to the existing method (the implicit plain text output may be deprecated afterwards, but it does need to go through the deprecation process).

data-ts="123443432"> can be added by unprivileged users to the parser output

That can be fixed by using data-mw-ts