Jens Ohlig has submitted this change and it was merged. Change subject: Fix an error in the lua api when the entity has no label or sitelink ......................................................................
Fix an error in the lua api when the entity has no label or sitelink If an entity has no label the entry "labels" doesn't exists in the table and made the script fail. Idem for sitelinks. Change-Id: I220996203ac88890ea8a2c50193e0932a907ddcd --- M client/resources/mw.wikibase.lua 1 file changed, 2 insertions(+), 2 deletions(-) Approvals: Jens Ohlig: Verified; Looks good to me, approved Daniel Kinzler: Looks good to me, but someone else must approve jenkins-bot: Checked diff --git a/client/resources/mw.wikibase.lua b/client/resources/mw.wikibase.lua index a696ce8..721da00 100644 --- a/client/resources/mw.wikibase.lua +++ b/client/resources/mw.wikibase.lua @@ -38,14 +38,14 @@ local code = mw.language.getContentLanguage():getCode() if code == nil then return nil end local entity = php.getEntity( id ) - if entity == nil then return nil end + if entity == nil or entity.labels == nil then return nil end local label = entity.labels[code] if label == nil then return nil end return label.value end wikibase.sitelink = function ( id ) local entity = php.getEntity( id ) - if entity == nil then return nil end + if entity == nil or entity.sitelinks == nil then return nil end local globalSiteId = php.getGlobalSiteId() if globalSiteId == nil then return nil end local sitelink = entity.sitelinks[globalSiteId] -- To view, visit https://gerrit.wikimedia.org/r/56737 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I220996203ac88890ea8a2c50193e0932a907ddcd Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Tpt <thoma...@hotmail.fr> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Jens Ohlig <jens.oh...@wikimedia.de> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits