Page MenuHomePhabricator

Metatables don't work from wikitext (__index)
Closed, ResolvedPublic


Create Module:Foo with the following code:
local p, mt = {}, {}

function mt.__index(table, key)
return function(frame)

		return 'You called the ' .. key .. ' function'


setmetatable(p, mt)

return p

From the console, "" correctly produces "You called the bar function". However, from wikitext, "{{#invoke:Foo|bar}}" instead produces "Script error: The function "bar" does not exist."

Version: unspecified
Severity: normal



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 3:19 AM
bzimport set Reference to bz64141.
bzimport added a subscriber: Unknown Object (MLST).

I don't currently have LuaSandbox set up, but while trying to fix this, I noticed that in LuaStandalone, passing an object from Lua to PHP and back causes its metatable to be lost.

Change 127458 had a related patch set uploaded by Jackmcbarn:
Keep modules' export tables inside Lua

Change 127458 merged by jenkins-bot:
Keep modules' export tables inside Lua

This will be live on all WMF wikis starting June 5th.