Page MenuHomePhabricator

Wikipedia.org portal search broken (no results, fetches from undefined.wikipedia.org)
Closed, ResolvedPublic

Description

  1. https://www.wikipedia.org/ in latest Chrome on macOS
  2. Typing in the search field

Actual:

  • No results.
  • Network inspection shows it is trying to fetch from https://undefined.wikipedia.org/w/api.php
GET https://undefined.wikipedia.org/w/api.php?action=query&format=json&generator=prefixsearch&prop=pageprops%7Cpageimages%7Cpageterms&redirects=&ppprop=displaytitle&piprop=thumbnail&pithumbsize=160&pilimit=6&wbptterms=description&gpssearch=e&gpsnamespace=0&gpslimit=6&callback=callbackStack.queue%5B0%5D
net::ERR_NAME_NOT_RESOLVED

Code versions:

Cookie
"GeoIP=GB:ENG:London:*:*:v4; CP=H2"
Local Storage
(length: 4)

lang-list-active: "false"
portal_session_id: "*"
portal_test_group_expires: "1503439955049"
translationHash: "b63ef08f"
Session Storage
(length: 0)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Krinkle triaged this task as Unbreak Now! priority.Aug 22 2017, 10:01 PM

This bug consistently happens in all browsers, including other language settings. After typing more characters, however, the results do work.

I traced the problem to a logic error in typehead.js at https://github.com/wikimedia/portals/blob/898ed0b11631ab5570202d82e72eb32c6d6dfdfe/dev/wikipedia.org/assets/js/wm-typeahead.js#L157-L164

The searchLang variable is initially declared undefined, and remains so until the first call to the typeahead function loadQueryScript(). This function creates a url to the API endpoint and makes the fetch, and this url embeds the value of searchLang. The variable searchLang, however, is not updated/declared until after the function defines the URL.

As such, the API url is always one step behind regarding value changes to searchLang , and this means initially it will try to fetch from undefined.wikipedia.org.

Krinkle lowered the priority of this task from Unbreak Now! to High.Aug 22 2017, 10:50 PM

Change 373360 had a related patch set uploaded (by Jdrewniak; owner: Jdrewniak):
[wikimedia/portals@master] Fix typeahead on first character

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

debt lowered the priority of this task from High to Medium.Aug 24 2017, 4:08 PM
debt added a project: Discovery-Portal-Sprint.
debt moved this task from Backlog to Needs code review on the Discovery-Portal-Sprint board.

Change 373360 merged by jenkins-bot:
[wikimedia/portals@master] Fix typeahead on first character

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

debt subscribed.

This was pushed to production on Sep 6, 2017

wikipedia-portal_auto-typeahead_fixed.png (697×571 px, 135 KB)

debt assigned this task to Jdrewniak.