Page MenuHomePhabricator

Lua: Make it possible to load only specific Statements using mw.wikibase
Closed, ResolvedPublic

Description

If one wants to access the raw statements from a certain Entity in Lua right now, they need to load the whole entity ([[https://www.mediawiki.org/wiki/Extension:Wikibase_Client/Lua#mw.wikibase.getEntity | mw.wikibase.getEntity]]). This poses two main problems: a) The whole entity needs to be serialized for Lua and b) we can't (without rather nasty hacks) tell which Statement(s) have been used.

Getting this new function in place will fix the aforementioned problems and also allow us to use more efficient storage mechanisms for loading individual Statements later on (so that the backend also doesn't need to load the full entity).

I propose:
mw.wikibase.getBestStatements( 'entity id', 'property id of statements to load' ). It returns a table like a call to mw.wikibase.getEntity( 'entity id' ):getBestStatements( 'property id of statements to load' ) would.

This new functionality should track statement usages (C.P123), but for now also other usages (O).

Event Timeline

Related: https://gerrit.wikimedia.org/r/336542

This adds statement specific usage tracking to entity tables.

Change 370956 had a related patch set uploaded (by Eranroz; owner: Eranroz):
[mediawiki/extensions/Wikibase@master] Adding a new mw.wikibase.getStatements

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

Change 370956 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Adding a new mw.wikibase.getBestStatements

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

This will be part of the next Wikibase deployment, thanks for doing this @eranroz.