@ RexxS: Remember the discussion we had on Mike Peel's talk page? I've implement Lua code to perform cross-checking against multiple Wikidata properties to look for Commons galleries or categories (or both). That is this module, which is currently in use at {{ commons and category}} and {{ commons and category-inline}}. I'd like to use it for {{ commons-inline}}, and perhaps {{ commons category}}. Before I do anything, would you be willing to look at the code and give me feedback? As usual, the testcases are here. Thanks for any help or suggestions you can provide! — hike395 ( talk) 15:48, 15 March 2020 (UTC)
{{#invoke:Commons link |getGallery |qid=Q0 |search=}}
→ The ID "Q0" is unknown to the system. Please use a valid entity ID. (← bad entity-id){{#invoke:Commons link |getGallery |qid=Q68979196 |search=}}
→ [[Commons:Special:Search/|]] (← entity-id exists, but has no links)qid = mw.wikibase.getEntityIdForCurrentPage()
– is it possible for the code to be running on a page that has no linked EntityID? If so, what happens when qid is returned as nil on line 16? Similarly for line 20, if mw.wikibase.sitelink(qid)
somehow manages to return nil (no sitelink). Incidentally, I'd recommend using the latest calls: mw.wikibase.getSitelink
is current, while mw.wikibase.sitelink
is a legacy alias and shouldn't be used in new code (per
mw:Extension:Wikibase Client/Lua #Legacy aliases).Some articles are showing "Lua error: bad argument #1 to 'getBestStatements' (string expected, got nil)". Examples:
Pastry,
Remote control. That is because qid
is nil in mw.wikibase.getBestStatements(qid, "P373")
at line 184. I'm hoping
Hike395 will investigate.
Johnuniq (
talk)
10:28, 2 August 2021 (UTC)
@ RexxS: Remember the discussion we had on Mike Peel's talk page? I've implement Lua code to perform cross-checking against multiple Wikidata properties to look for Commons galleries or categories (or both). That is this module, which is currently in use at {{ commons and category}} and {{ commons and category-inline}}. I'd like to use it for {{ commons-inline}}, and perhaps {{ commons category}}. Before I do anything, would you be willing to look at the code and give me feedback? As usual, the testcases are here. Thanks for any help or suggestions you can provide! — hike395 ( talk) 15:48, 15 March 2020 (UTC)
{{#invoke:Commons link |getGallery |qid=Q0 |search=}}
→ The ID "Q0" is unknown to the system. Please use a valid entity ID. (← bad entity-id){{#invoke:Commons link |getGallery |qid=Q68979196 |search=}}
→ [[Commons:Special:Search/|]] (← entity-id exists, but has no links)qid = mw.wikibase.getEntityIdForCurrentPage()
– is it possible for the code to be running on a page that has no linked EntityID? If so, what happens when qid is returned as nil on line 16? Similarly for line 20, if mw.wikibase.sitelink(qid)
somehow manages to return nil (no sitelink). Incidentally, I'd recommend using the latest calls: mw.wikibase.getSitelink
is current, while mw.wikibase.sitelink
is a legacy alias and shouldn't be used in new code (per
mw:Extension:Wikibase Client/Lua #Legacy aliases).Some articles are showing "Lua error: bad argument #1 to 'getBestStatements' (string expected, got nil)". Examples:
Pastry,
Remote control. That is because qid
is nil in mw.wikibase.getBestStatements(qid, "P373")
at line 184. I'm hoping
Hike395 will investigate.
Johnuniq (
talk)
10:28, 2 August 2021 (UTC)