Page MenuHomePhabricator

Hovercards: TypeError: page.revisions is undefined on Preferences reset link
Closed, ResolvedPublic

Description

On en beta, visit preferences and then hover over the link _Restore all default settings (in all sections)_

JS console reports an error
TypeError: page.revisions is undefined

it's coming from line 98 in ext.popups.core.js in curRequest.done

timestamp = new Date( page.revisions[ 0 ].timestamp ),

the API request I think it's handling is
http://en.wikipedia.beta.wmflabs.org/w/api.php?action=query&format=json&prop=extracts|pageimages|revisions|info&redirects=true&exintro=true&exsentences=2&explaintext=true&piprop=thumbnail&pithumbsize=300&rvprop=timestamp&inprop=watched&indexpageids=true&titles=Special%3APreferences%2Freset

which returns only
{"query":{\

"pageids":["-1"],
"pages":{"-1":{"ns":-1,"title":"Special:Preferences/reset","special":""}}}

}

  1. There's no page.revisions for a Special page, so error. Test before accessing nested keys.
  1. It seems the code should give up before this anyway, since page.extract and page.thumbnail are both undefined. That would avoid showing empty popups with a timestamp.
  1. This gets through the popup link tests around line 516 because the link is to /wiki/Special:Preferences/reset, so no "#" or "?. There are other special page links that would pass this. Maybe the code should test if the namespace of the page is -1.

Version: master
Severity: normal
URL: http://en.wikipedia.beta.wmflabs.org/wiki/Special:Preferences?debug=1
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=64065

Details

Reference
bz64522