Page MenuHomePhabricator

Gadget does not open for logged out users
Closed, InvalidPublic2 Estimated Story PointsBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Edit any page in the main namespace while logged out of any Wikimedia account.

What happens?:

The button to open the gadget does not appear in the page and the console shows the following error:

Uncaught (in promise) TypeError: can't access property "gender", json.query.users[0] is undefined
    getGender user.js.js:31
user.js.js:31:3

What should have happened instead?:

The button to open the gadget should appear above the edit form.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):
Gadget version: 6.5.0

Event Timeline

Danya claimed this task.
Danya triaged this task as High priority.
Danya set the point value for this task to 2.
Danya moved this task from Backlog to High Priority Backlog on the gadget-create-new-entry board.
Danya moved this task from High Priority Backlog to Next Version on the gadget-create-new-entry board.

Cause:
In getGender() of MediaWiki:Gadget-wikt.core/user.js, the API query returns an empty users array when the function expects at least one element:

async function getGender(api, username) {
  const params = {
    action: "query",
    list: "users",
    ususers: username || mw.config.get("wgUserName"),
    usprop: "gender",
    format: "json",
    formatversion: 2,
  };
  const json = await api.get(params);
  return json.query.users[0].gender;
}
Danya moved this task from Next Version to Done on the gadget-create-new-entry board.

The bug comes from an external dependency. This was fixed directly on the wiki.