Page MenuHomePhabricator

Remove most of mw.wikibase.lexeme module (remove getLemmas, getLanguage, getLexicalCategory; keep splitLexemeId)
Closed, ResolvedPublic

Description

Currently, the mw.wikibase.lexeme module has the following methods:

  • getLemmas( id )
  • getLanguage( id )
  • getLexicalCategory( id )
  • splitLexemeId( id )

The first three are equivalent to calling the method of the same name, without arguments, on the result of mw.wikibase.getEntity( id ). I propose we remove them, to reduce duplication in the interface; I don’t think it’s useful to have them. (splitLexemeId is useful and can be kept, it’s not a method that can be called on an individual lexeme entity.)

In Wikibase, for items and properties, there’s similar duplication in some methods (related to labels and descriptions). However, Wikibase can actually look up item/property labels/descriptions more efficiently in this case, by getting them from the term store, without loading the full entity. For lexemes, there’s no such secondary storage, and getLemmas/getLanguage/getLexicalCategory are implemented in PHP by loading the full entity and getting the information from it, which is only marginally more efficient than loading the full entity into Lua and then getting the information from it there. In this way, I think the mw.wikibase.lexeme functions are not only redundant, but arguably confusing, since users familiar with the Wikibase lua interface might expect those functions to not count against the entity limit, whereas they actually do count against it. And I don’t think we’ll have a secondary storage comparable to the terms store for lexemes in the foreseeable future; if we add it at some point, we can still add those functions then, when they actually have the potential to be more efficient.

Event Timeline

Note in Wikibase we also have mw.wikibase.getAllStatements and mw.wikibase.getBestStatements which are not even expensive functions and the are optimized for their purposes.

Hm, I don’t think that’s correct? We don’t have a secondary statements store like we have a terms store; the statements functions are implemented by loading the whole entity, as far as I can tell, and it looks like if you call them on too many entities, you’ll get an error:

Screenshot 2021-12-09 at 17-54-44 Creating Module Blank - Wikidata.png (205×629 px, 11 KB)

There are no indication of such in documentation.

Alright, let’s clear that up in T297412: Correctly mark getAllStatements and getBestStatements functions as expensive. But to me that’s not sufficient reason to keep the lexeme functions.

Change 745568 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/WikibaseLexeme@master] Remove most of mw.wikibase.lexeme Lua module

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

Change 745568 merged by jenkins-bot:

[mediawiki/extensions/WikibaseLexeme@master] Remove most of mw.wikibase.lexeme Lua module

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

Change 746813 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/WikibaseLexeme@wmf/1.38.0-wmf.12] Remove most of mw.wikibase.lexeme Lua module

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

Change 746813 merged by jenkins-bot:

[mediawiki/extensions/WikibaseLexeme@wmf/1.38.0-wmf.12] Remove most of mw.wikibase.lexeme Lua module

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

Mentioned in SAL (#wikimedia-operations) [2021-12-13T15:49:37Z] <lucaswerkmeister-wmde@deploy1002> Synchronized php-1.38.0-wmf.12/extensions/WikibaseLexeme: Backport: [[gerrit:746813|Remove most of mw.wikibase.lexeme Lua module (T297404)]] (no-op because Lexeme Lua is not yet enabled in prod) (duration: 00m 58s)

Change 746906 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/WikibaseLexeme@wmf/1.38.0-wmf.9] Remove most of mw.wikibase.lexeme Lua module

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

Change 746906 merged by jenkins-bot:

[mediawiki/extensions/WikibaseLexeme@wmf/1.38.0-wmf.9] Remove most of mw.wikibase.lexeme Lua module

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

Mentioned in SAL (#wikimedia-operations) [2021-12-13T17:45:33Z] <lucaswerkmeister-wmde@deploy1002> Synchronized php-1.38.0-wmf.9/extensions/WikibaseLexeme: Backport: [[gerrit:746906|Remove most of mw.wikibase.lexeme Lua module (T297404)]] (no-op because Lexeme Lua is not yet enabled in prod) (duration: 00m 58s)