Page MenuHomePhabricator

Decide how to make mw.wikibase.getReferencedEntityId (or a new function) useful to lookup referenced entity ids based on multiple starting points
Open, Needs TriagePublic

Description

In the Wikibase Lua api, we provide a method [[ https://www.mediawiki.org/wiki/Extension:Wikibase_Client/Lua#mw.wikibase.getReferencedEntityId | mw.wikibase.getReferencedEntityId ]] which a user can use to for example walk up a subclass of chain.

This can for example be used to answer a question like: Is art museum (Q207694) a (possibly indirect) subclass of museum (Q33506)?

But for a many real-world use cases this doesn't suffice. For example if you want to know whether Museum of Modern Art (Q188740) is a museum, you currently have three instance of statements to check (like wdt:P31/wdt:P279* in SPARQL). In order to do that, you could make three calls to mw.wikibase.getReferencedEntityId (which would already eat up the entire call limit, as that function can only be called three times on a page).

In order to address this, we need to either alter mw.wikibase.getReferencedEntityId so that we can take into account all instance of statements from a given entity or add a new function that does exactly this.

This task is about choosing a new call signature (either for the currently existing function, or for a new one).

A possible way this could look like is wikibase.getReferencedEntityId( fromEntityId, { rootPropertyId = 'P31', edgePropertyId = 'P279' }, toIds ), but that doesn't seem very intuitive to me. Also a new function like wikibase.newFunctionName( fromEntityId, rootPropertyId, edgePropertyId, toIds ) seems not very intuitive to use.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Another possible signature: wikibase.getReferencedEntityId( { ...fromEntityIds }, propertyId, { ...toIds } ). (Some previous discussion for this is in T179155#4104367 and following comments.)

Another possible signature: wikibase.getReferencedEntityId( { ...fromEntityIds }, propertyId, { ...toIds } ). (Some previous discussion for this is in T179155#4104367 and following comments.)

I like that because it's so so simple. The only drawback I see, besides that it's a little less convenient, that it's harder to limit… do we limit the total number of calls and the total(?) number of fromEntityIds? But in general, I like that very much.