Originally reported at https://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_(technical)&oldid=919079997#Tens_of_thousands_of_new_articles_in_Category:Pages_with_script_errors
When an #invoke is in an argument to another #invoke, mw.getCurrentFrame() called at the module scope will return the outer #invoke's frame rather than the expect frame for the inner #invoke.
Consider these modules
local p = {} function p.echo( frame ) return '(Outer: 1=' .. frame.args[1] .. ', 2=' .. frame.args[2] .. ')' end return p
local p = {} local f = mw.getCurrentFrame() local name = f:getTitle() local arg1 = f.args[1] function p.test( frame ) local f2 = mw.getCurrentFrame() return '(Inner: mod_name=' .. name .. ', mod_1=' .. arg1 .. ', name=' .. f2:getTitle() .. ', 1='.. f2.args[1] .. ')' end return p
If you invoke {{#invoke:Inner|test|innerarg}} you get "(Inner: mod_name=Module:Inner, mod_1=innerarg, name=Module:Inner, 1=innerarg) " as expected.
But if you invoke {{#invoke:Outer|echo|outerarg|{{#invoke:Inner|test|innerarg}}}}, you unexpectedly get "(Outer: 1=outerarg, 2=(Inner: mod_name=Module:Outer, mod_1=outerarg, name=Module:Inner, 1=innerarg)) "