Last modified: 2014-05-27 00:13:05 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T66141, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 64141 - Metatables don't work from wikitext (__index)
Metatables don't work from wikitext (__index)
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Scribunto (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-04-19 19:57 UTC by Jackmcbarn
Modified: 2014-05-27 00:13 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Jackmcbarn 2014-04-19 19:57:40 UTC
Create Module:Foo with the following code:
local p, mt = {}, {}

function mt.__index(table, key)
	return function(frame)
		return 'You called the ' .. key .. ' function'
	end
end

setmetatable(p, mt)

return p

From the console, "=p.bar()" correctly produces "You called the bar function". However, from wikitext, "{{#invoke:Foo|bar}}" instead produces "Script error: The function "bar" does not exist."
Comment 1 Jackmcbarn 2014-04-19 21:15:25 UTC
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.
Comment 2 Gerrit Notification Bot 2014-04-20 03:44:30 UTC
Change 127458 had a related patch set uploaded by Jackmcbarn:
Keep modules' export tables inside Lua

https://gerrit.wikimedia.org/r/127458
Comment 3 Gerrit Notification Bot 2014-05-27 00:12:06 UTC
Change 127458 merged by jenkins-bot:
Keep modules' export tables inside Lua

https://gerrit.wikimedia.org/r/127458
Comment 4 Jackmcbarn 2014-05-27 00:13:05 UTC
This will be live on all WMF wikis starting June 5th.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links