(Note: I do not fully understand the defect, so I will try to detail as much as possible. My apologies in advance for the length.)
Summary
Scribunto allows creation of invalid scripts that will fail when invoked. The invalid script appears to be related to reusing object references for module variables:
local colors = {}
do
local FRA = {val = 1} colors.FRA = FRA colors.MTQ = FRA
end
p.colors = colors
Reproduction
- Create a module called "Module:Infobox_road/color"
- Copy the latest version from enwiki: http://en.wikipedia.org/w/index.php?title=Module:Infobox_road/color&oldid=552689438
- Go to any page and run the following
{{#invoke:Infobox_road/color|color}}
On Linux, "Fatal exception of type ScribuntoException" is generated
On Windows, "The interpreter exited with status 1" is generated
On http://en.wikipedia.org/w/index.php?title=Wikipedia:Sandbox&action=edit, "'background:#cedff2;'" is generated.
Workaround
- Find the following section in the above script colors.FRA = FRA colors.MTQ = FRA
- Delete the line "colors.MTQ = FRA"
- Rerun the #invoke. The page will now generate "'background:#cedff2;'".
Notes
- The Infobox_road/color module can be reduced to the following
local p = {}
local colors = {}
do
local FRA = {val = 1} colors.FRA = FRA colors.MTQ = FRA
end
p.colors = colors
function p.color(frame)
return 'color_val'
end
return p
This will generate the same error. Removing "colors.MTQ = FRA" will fix the issue
- I do not know why I get different error messages on both machines. They are both running MediaWiki 1.21 on PHP 5.4 with the latest master of Scribunto (as of today). If this cannot be reproduced, please let me know your version of MediaWiki / Scribunto / PHP / OS and I will try to reproduce with it.
- I do not know why http://en.wikipedia.org does not fail when invoking the same. My best guess is that there may be some version discrepancy with English Wikipedia in either Lua or Scribunto.
Version: master
Severity: normal