Page MenuHomePhabricator

Lua functions do not resolve redirects
Open, HighPublic


In a module debug console on a Wikidata client (Q404 is a redirect to Q395):

= mw.wikibase.label('Q404')
= mw.wikibase.getEntity('Q404')
= mw.wikibase.getEntity('Q404').id
= mw.wikibase.label('Q395')

Loading labels doesn't resolve the redirect, while loading the whole entity does.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFeb 11 2017, 1:51 PM
Lydia_Pintscher moved this task from incoming to ready to go on the Wikidata board.May 5 2017, 3:27 PM
Lydia_Pintscher added a subscriber: hoo.
Lydia_Pintscher triaged this task as Medium priority.Jun 11 2017, 4:45 PM
Larske added a subscriber: Larske.Jan 5 2018, 12:59 AM
Salgo60 added a subscriber: Salgo60.Jan 5 2018, 4:54 AM
hoo moved this task from Incoming to To do next on the Wikibase-Lua board.Apr 12 2018, 1:57 PM
Uzume added a subscriber: Uzume.Apr 12 2018, 2:56 PM

T143970 seems like it was recently closed but I still think we need a resolveEntityId(eid) that returns nil when there is no such entity but redirects for merged items, etc. It could also potentially work like resolvePropertyId and return a valid entity ID when given an unambiguous label or alias.

This might get resolved by T112658.

This might get resolved by T112658.

Tested it (for label) with the patchset suggested in T112658 but this will not resolve it - requiring a different fix as part of T142950

I don't understand why this doesn't have high priority. It makes the functions mw.wikibase.getLabel( id ), mw.wikibase.getDescription( id ), and mw.wikibase.getSitelinkl( id ) unreliable for IDs obtained from a module's arguments or from statement values of type wikibase-entityid in other entities.

Thus you are forced to use the expensive mw.wikibase.getEntity( id ) and entity:getLabel(), entity:getDescription(), and entity:getSitelink() to get reliable results.

Ahecht added a subscriber: Ahecht.Oct 4 2018, 11:01 PM
Mike_Peel raised the priority of this task from Medium to High.Jul 10 2019, 5:56 PM
Mike_Peel added subscribers: RexxS, Mike_Peel.

We've just come across this issue on Commons, see discussion at . I've increased it to high priority.

I've come across this issue when using Template:Wikidata_list / ListeriaBot.
If an item in the list contains a reference to a WD object that was merged to another one, the label is not shown.

Examples can be found here: