hoo added a comment.

I still don't find consistence between the fix and mine old debugged sandbox patch, that I re-report:

-- ...
label    = 'Normal: ' .. item
sitelink = 'Absurd: ' .. item
-- ...

Both these assignments read from the same stack state but apparently both receive different values of item. The first receives Q321 and the second Q123 as reported in the output [[w:en:Absurd: Q123September|Normal: Q321]].

Ghosts.

Alright, I reduced this test case:

p = {}

function p._getLabel(item, lang, link_type, capitalization)
	local entity, langList, s, sitelink, label, dLink, userLang

	-- Lua nonsense?
	label = 'Normal: ' .. item
	sitelink = 'Absurd: ' .. item

	if not link then-- apply default "Wikipedia" link type
		sitelink = sitelink .. 'TheSiteLink' -- "DEBUG"
		link = mw.ustring.format('w:%s:%s', lang, sitelink)
	end

	-- return the results
	if link~='' then
		return mw.ustring.format('[[%s|%s]]', link, label) -- return link
	else
		return label -- return just a label
	end
end

return p

Yields:

= p._getLabel( 'Q2', 'de' )
[[w:de:Absurd: Q2TheSiteLink|Normal: Q2]]
= p._getLabel( 'Q3', 'de' )
[[w:de:Absurd: Q2TheSiteLink|Normal: Q3]]

As explained above, this happens as (after the first run) link is set globally, thus the first if is not executed, leading to the old value (from the first function call) being placed in link, instead of the current/ new value of sitelink.


TASK DETAIL
https://phabricator.wikimedia.org/T173194

EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Jarekt, hoo
Cc: valerio.bozzolan, Izno, daniel, Multichill, Aklapper, Ricordisamoa, JeanFred, Jarekt, ValterVB, Elitre, Jheald, Daniel_Mietchen, Nemo_bis, Aschroet, zhuyifei1999, Steinsplitter, Matanya, RP88, El_Grafo, Revent, Sjoerddebruin, Jane023, Susannaanas, Mike_Peel, Lydia_Pintscher, Micru, intracer, Poyekhali, Nizil, PokestarFan, hoo, E1presidente, Ramsey-WMF, Jmmuguerza, SandraF_WMF, GoranSMilovanovic, QZanden, Acer, Vali.matei, Volker_E, Wong128hk, Wikidata-bugs, PKM, Base, matthiasmullie, aude, GWicke, Fabrice_Florin, Raymond, Mbch331, Jay8g
_______________________________________________
Wikidata-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to