Module talk:ResolveEntityId: Difference between revisions

Content deleted Content added
clarify
Tag: Reverted
 
(21 intermediate revisions by 4 users not shown)
Line 3:
{{ping|Ahecht}} a really useful module. Would it possible to follow redirects and give the ID of their target? &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 17:07, 22 June 2021 (UTC)
 
:{{ping|MSGJ}} It already follows Wikidata redirects. For example {{mlx|ResolveEntityId|entityid|Q404}} returns {{#invoke:ResolveEntityId|entityid|Q404}}. Are you talking about following Wikipedia redirects as well? UInless I'm mistaken, since redirects typically don't have Wikidata entries, this would require an expensive function call to retrieve the redirect target. --[[User:Ahecht|Ahecht]] ([[User talk:Ahecht|<span style="color:#FFF;background:#04A;display:inline-block;padding:1px;vertical-align:-.3em;font:bold 50%/1 sans-serif;text-align:center">TALK<br />PAGE</span>]]) 20:00, 24 June 2021 (UTC)
::Yes that's what I meant, sorry if I was unclear. It would be great if
::*<nowiki>{{#invoke:ResolveEntityId|entityid|Isla de Útila}}</nowiki> ⇒ Q1572113
::Currently:
::*<nowiki>{{#invoke:ResolveEntityId|entityid|Isla de Útila}}</nowiki> ⇒ {{#invoke:ResolveEntityId|entityid|Isla de Útila}}
::&mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 21:00, 24 June 2021 (UTC)
::{{ping|Ahecht}} this would still be extremely useful, if only as an opt-in. Thanks :) &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 20:54, 23 February 2022 (UTC)
:::@[[User:MSGJ|MSGJ]] I'll put it on my to-do list. --[[User:Ahecht|Ahecht]] ([[User talk:Ahecht|<span style="color:#FFF;background:#04A;display:inline-block;padding:1px;vertical-align:-.3em;font:bold 50%/1 sans-serif;text-align:center">TALK<br />PAGE</span>]]) 05:03, 24 February 2022 (UTC)
:::@[[User:MSGJ|MSGJ]] Looks like I implemented it in the sandbox back in 2021 but never copied it to the main template. It's now {{done}}<!-- Template:ETp -->. --[[User:Ahecht|Ahecht]] ([[User talk:Ahecht|<span style="color:#FFF;background:#04A;display:inline-block;padding:1px;vertical-align:-.3em;font:bold 50%/1 sans-serif;text-align:center">TALK<br />PAGE</span>]]) 22:39, 24 February 2022 (UTC)
::::{{U|Ahecht}} and {{U|MSGJ}}: Something, possibly this change, has resulted in script errors in as many as a few hundred articles. See [[Abatus koehleri]] and {{cl|Pages with script errors}}. – [[User:Jonesey95|Jonesey95]] ([[User talk:Jonesey95|talk]]) 01:30, 25 February 2022 (UTC)
::::Reverted for now. Thanks for letting us know &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 08:28, 25 February 2022 (UTC)
:::::If the reverted edit is restored, perhaps with changes, please consider my response at [[WT:Lua#Lua error with Taxonbar?]]. I don't know if the problem mentioned here had the same root cause as the problem I investigated. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 08:38, 25 February 2022 (UTC)
Ahecht: while you are debugging this, can you just confirm that if the redirect does have a wikidata item then the module should return that ID. It should only follow the redirect if there is no wikidata item. I may be reading the code wrong, but it seems that line 25 of your sandbox may need changing. Thanks &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 08:48, 25 February 2022 (UTC)
 
:{{ping|MSGJ|Jonesey95|Johnuniq}} I think I have it resolved now. There was an earlier change to the sandbox before I made my changes that caused an error if there wasn't a Wikipedia sitelink in the Wikidata item (which wasn't in my testcases). I have fixed that issue in my sandbox, and implemented it in {{tl|taxonbar/sandbox}}. I also fixed the sandbox so that it only resolves redirects if a wikidata item doesn't exist. Please test out the new sandbox version, and I can copy it over to the main module. --[[User:Ahecht|Ahecht]] ([[User talk:Ahecht|<span style="color:#FFF;background:#04A;display:inline-block;padding:1px;vertical-align:-.3em;font:bold 50%/1 sans-serif;text-align:center">TALK<br />PAGE</span>]]) 00:14, 26 February 2022 (UTC)
::{{ping|Ahecht}} Please review the history at [[Module:ResolveEntityId/sandbox]] and check the edits I have made. Re [[Module:ResolveEntityId/doc]], you might consider rewriting the examples like the following.<syntaxhighlight lang="lua" indent="1">
local resolveId = require('Module:ResolveEntityId')._id
id = resolveId('Q42')
</syntaxhighlight>
::[[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 03:58, 26 February 2022 (UTC)
:::@[[User:Johnuniq|Johnuniq]] Looks good. I simplified the code a little further, and will run some more tests before taking it live. --[[User:Ahecht|Ahecht]] ([[User talk:Ahecht|<span style="color:#FFF;background:#04A;display:inline-block;padding:1px;vertical-align:-.3em;font:bold 50%/1 sans-serif;text-align:center">TALK<br />PAGE</span>]]) 05:28, 26 February 2022 (UTC)
::::My tests on [[Module talk:ResolveEntityId/testcases]] are all working correctly. &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 16:44, 27 February 2022 (UTC)
::::Ahecht: Do you think this is ready to deploy? &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 10:34, 2 March 2022 (UTC)
I don't have an opportunity to fully investigate at the moment but [[Cobble skink]] is showing "Lua error in Module:ResolveEntityId at line 32: attempt to index a nil value" at the bottom due to a recent edit here. Perhaps it's a problem in that article that someone could fix, although the module should show a better message. Every function related to titles or wikidata will potentially return nil or give some other error at some point. It's a shame that code has to be uglified but the fix there would be something like "local title = mw.title.new(...) or error('helpful text here')" then use title.redirectTarget. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 23:13, 7 March 2022 (UTC)
:It was caused by an empty definition of from1, i.e.
<pre>{{Taxonbar|from1=|from2=Q106918135}}</pre>
:[[Module:Taxonbar]] or this module need to be made more robust so that a blank input does not cause an error &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 18:02, 8 March 2022 (UTC)
 
== Output for invalid input ==
 
Could the module be made a bit more robust? If something invalid is passed to the template, e.g.
<pre>{{#invoke:ResolveEntityId|entityid|[[Kouga Dam]]}}</pre>
could it fail gracefully by returning nil? At the moment we are getting "Lua error in Module:ResolveEntityId at line 32: attempt to index a nil value". Cheers &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 09:25, 2 November 2022 (UTC)
 
:Since I realised I had already requested this previously, I went ahead and made the corrections to the module. Hope there are no side-effects but testcases are working fine. &mdash;&nbsp;Martin <small>([[User:MSGJ|MSGJ]]&nbsp;·&nbsp;[[User talk:MSGJ|talk]])</small> 15:34, 2 November 2022 (UTC)