Modulo:Wikidata: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Annullata la modifica 93094948 di Rotpunkt (discussione) va utilizzato solo su richiesta del modulo chiamante tramite un parametro altrimenti causa l'aumento di utilizzo di memoria dedicata a Lua
Riga 47:
}
}
 
-- Table per la funzione getEntityCached
local entitiesCache = {}
 
local p = {}
Riga 385 ⟶ 382:
-- Lettura e selezione statement
-------------------------------------------------------------------------------
 
-- Versione con cache di mw.wikibase.getEntity
local function getEntityCached(entityId)
local ret
entityId = entityId or mw.wikibase.getEntityIdForCurrentPage()
if entityId then
ret = entitiesCache[entityId]
if not ret then
ret = mw.wikibase.getEntity(entityId)
if ret then
entitiesCache[entityId] = ret
end
end
end
return ret
end
 
-- Restituisce true se lo statement contiene il qualifier richiesto con un dato valore
Riga 436 ⟶ 417:
-- get entity
entity = getEntityCachedmw.wikibase.getEntity(args.from)
if not entity then
return nil
Riga 675 ⟶ 656:
-- Restituisce l'etichetta di un item o di una proprietà Wikidata.
function p._getLabel(args)
local entity = getEntityCachedmw.wikibase.getEntity(args[1] and string.upper(args[1]))
return entity and entity:getLabel(args[2])
end
Riga 700 ⟶ 681:
end
 
entity = getEntityCachedmw.wikibase.getEntity(property)
if not entity then
error(i18n.errors['entity-not-found'], 2)