Page MenuHomePhabricator

OutputPage::getRevisionTimestamp on (de|hu).wikipedia returning incorrect values for anonymous users
Closed, ResolvedPublic

Description

On German Wikipedia for anonymous page views the last modified bar is showing an incorrect time.

Steps to reproduce:

Expected: The timestamps of the last edit is somewhere in the past (when the last edit occurred) and the bar is gray
Actual: It says that the page was edited just now and it is green. When you click to the history page however this is not true.

I tried in other wikis, but I could only reproduce this issue in de.wikipedia. Also note that the timestamp in classical view is correct for all users.

On Nov 15 history bar is green suggesting it's just been edited.

Screen Shot 2017-11-15 at 9.49.40 AM.png (264×1 px, 50 KB)

Last edit however says it hasn't been edited since April:

Screen Shot 2017-11-15 at 9.49.49 AM.png (346×1 px, 38 KB)

Possibly related: The history link is also not showing at all on certain anonymous page views: T180116

Developer notes

I can replicate this only on German Wikipedia

The timestamp is provided by:

$this->getOutput()->getRevisionTimestamp();

Somehow that is being reported incorrectly for anonymous page views

It is possible something on German Wikipedia is calling setRevisionTimestamp in an incorrect way:
https://github.com/search?q=org%3Awikimedia+setRevisionTimestamp&type=Code

In core:

$timestamp = $this->getOutput()->getRevisionTimestamp();

# No cached timestamp, load it from the database
if ( $timestamp === null ) {
        $timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->getRevisionId() );
}

In Minerva

$timestamp = $this->getOutput()->getRevisionTimestamp();
'data-timestamp' => $isMainPage ? '' : wfTimestamp( TS_UNIX, $timestamp ),

Given the timestamp is not null or empty string, it seems unrelated to the call to getTimestampFromId

@Tgr suggests that we should add the fallback step to Minerva and see if that remedies the problem - https://phabricator.wikimedia.org/T180103#3757401

Additional info from @EddieGP

I browsed a page on dewp this morning and was surprised by the footer bar saying "Last edited 10 hours ago by EddieGP". The relevant page is https://de.m.wikipedia.org/wiki/Digitalfunk_der_Beh%C3%B6rden_und_Organisationen_mit_Sicherheitsaufgaben . I indeed am the last one who edited that page, but that was four month ago (by July), not yesterday. So I looked into it a bit and saw that my phone is served a different time stamp for the "last edited" field than my laptop (when using mobile view). Looking on the html source on my laptop, within "footer div.last-modified-bar div.content div.last-modifier-tagline":

<a href="/wiki/Spezial:Versionsgeschichte/Digitalfunk_der_Beh%C3%B6rden_und_Organisationen_mit_Sicherheitsaufgaben" data-user-name="EddieGP" data-user-gender="male" data-timestamp="1500822350">Zuletzt bearbeitet am 2017-07-23 um 15:05:50</a>
On my phone, it looks like this:
Screenshot_20171115-044903.png (1×1 px, 110 KB)
Turning off js, so I can see exactly at which time it says to be last edited:
Screenshot_20171115-045706.png (1×1 px, 139 KB)
Looking into the source code on my mobile, I get the timestamp "1510680482":
Screenshot_20171115-115451.png (1×1 px, 327 KB)

My phone is a oneplus2, and I'm on Firefox 56.0, Android 7.1.2. I could reprodiuce this on my phone with Chrome 62.0.3202.84.

Event Timeline

Jdlrobson renamed this task from Mobile version of de.wikipedia shows wrong timestamp of last edit for users not logged in to OutputPage::getRevisionTimestamp on de.wikipedia returning incorrect values for anonymous users.Nov 13 2017, 5:02 PM
Jdlrobson edited projects, added MediaWiki-General, MinervaNeue; removed MobileFrontend.
Jdlrobson updated the task description. (Show Details)
Jdlrobson added a project: Web-Team-Backlog.
Jdlrobson added subscribers: daniel, greg, Jdlrobson.

I can indeed replicate this.
The fact this is on German Wikipedia only and code hasn't been touched in long long time makes me very suspicious that something is interfering.
The timestamp being rendered for anonymous page views is incorrect.

@daniel @greg have there been any Wikimedia DE only deployments recently that might be causing this?

Jdlrobson moved this task from Incoming to Needs Prioritization on the Web-Team-Backlog board.

Since flagged revisions is enabled on dewiki this would be my first theory of where to look....

@Tgr - any theories on what might be happening here given your knowledge of the stack?

Can reproduce on huwiki but not on fiwiki (both are flagrev wikis).

Jdlrobson renamed this task from OutputPage::getRevisionTimestamp on de.wikipedia returning incorrect values for anonymous users to OutputPage::getRevisionTimestamp on (de|hu).wikipedia returning incorrect values for anonymous users.Nov 14 2017, 12:41 AM

The difference between the skins is in all likeliness the fallback to the DB in Skin::lastModified() so the easy solution is to just do that.

OutputPage::$mRevisionTimestamp is probably set in Article::view(), in case 2 of the huge switch, where it uses the parser cache. Both affected and non-affected wikis return the correct timestamp so not quite sure what's going on:

tgr@terbium:~$ mwscript shell.php --wiki=huwiki
>>> $title = Title::newFromText('Marie-Anne_de_Mailly-Nesle')
>>> $ctx = RequestContext::newExtraneousContext( $title );
>>> $parserCache = \MediaWiki\MediaWikiServices::getInstance()->getParserCache();
>>> $page = WikiPage::factory( $title );
>>> $po = $page->makeParserOptions( $ctx );
>>> $popt = $page->makeParserOptions( $ctx );
>>> $po = $parserCache->get( $page, $popt );
>>> $po->getTimeStamp();
=> "20160920203415"
Jdlrobson updated the task description. (Show Details)

T180581 is in all likeliness the same issue (Minerva getting a null from OutputPage::getRevisionTimestamp() and then passing that to wfTimestamp() which will result in the current time) plus varnish or client caching the HTML for 10 hours (the "edited X hours ago" thing being JS-generated from an absolute timestamp).

Change 391977 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/skins/MinervaNeue@master] If timestamp is null load revision time

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

@Tgr yeh that does look like what's happening here. Review welcomed :)

pmiazga subscribed.

Bringing into the current sprint for visibility.

pmiazga moved this task from To Do to Needs QA on the Readers-Web-Kanbanana-Board-Old board.

To verify this task code has to hit production (de|hu) as it is difficult to test it locally. Moving to blocked as first we need to deploy this to de|hu wiki. Otherwise I don't know how to test it properly.

Change 391977 merged by jenkins-bot:
[mediawiki/skins/MinervaNeue@master] If timestamp is null load revision time

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

We'll pull it into next sprint. No need to track it here as it will just be blocked for 2 weeks.
I'm not 100% it's going to solve the problem, although it seems like it will, but we can talk about it in a future grooming.

Jdlrobson changed the task status from Open to Stalled.Nov 21 2017, 5:52 PM
Jdlrobson added a project: User-Jdlrobson.
Jdlrobson moved this task from Inbox to Blocked on the User-Jdlrobson board.
Jdlrobson claimed this task.

Looks fixed to me!

Looks fixed to me!

Besides caching (after purging), for me too. Thanks!