Page MenuHomePhabricator

Wikidata page shows "Lua error: not enough memory"
Closed, DeclinedPublic

Description

This page: https://www.wikidata.org/wiki/Wikidata:Menu_Challenge/participants#User:OrenBochman
shows Lua out of memory errors in the section starting with the anchor part of the URL above.

Event Timeline

Ijon raised the priority of this task from to Needs Triage.
Ijon updated the task description. (Show Details)
Ijon subscribed.

I took a look at the lua module that is ultimately used here.

https://www.wikidata.org/wiki/Module:Wikidata

It uses mw.wikibase.getEntityObject to load the entire entity and then get just the label, afaik in just the content language of Wikidata. In this case, we are also dealing with access to arbitrary items, which is expensive. That means there is a limit on the number of entities we can load per page.

It would be better if the module used the mw.wikibase.label convenience when possible. It uses a term lookup (wb_terms table) to get individual labels without loading the entire entity, so is less expensive and can be done more times on a page.

in https://www.wikidata.org/wiki/User:Aude/menu_challenge2, using a copy of the module, https://www.wikidata.org/wiki/Module:Wikidata_test, I tried the following code and (although somewhat ugly) it seems to work better including in other languages than English.

function p._getLabel(entity, lang, default)
	local label
 
	if lang == defaultlang then
		label = mw.wikibase.label(entity)
 
		if not label then
			return defaultlabel(entity, lang, default)
		end
 
		return label
	end
 
	if not entity then
		return nil
	end
	if type(entity) ~= 'table' then
		entity = p.getEntity(entity)
	end
	if (not entity) or (not entity.labels) then
		return entity--defaultlabel(entity, lang, default)
	end
	for i, lg in pairs(fb.fblist(lang or defaultlang)) do
		if entity.labels[lg] then
			return entity.labels[lg].value
		end
	end
	return defaultlabel(entity, lang, default)
end

if mw.wikibase.label() also took a 'lang' param, then perhaps it could always and be the only thing used in p._getLabel

aude added a subscriber: hoo.
Lydia_Pintscher claimed this task.
Lydia_Pintscher subscribed.

Thanks for the report. This needs to be fixed on-wiki in the Lua module.