Page MenuHomePhabricator

Assigning built-in functions to module export throws error
Closed, ResolvedPublicBUG REPORT

Description

Observed on cswiki since around 2019-10-21 14:40 UTC.

Steps to Reproduce:

Create a lua module with this content:

local p = {}

p.myFunc = mw.wikibase.getEntityIdForCurrentPage

p.myFunc2 = mw.isSubsting

p.getCurrentTitle = mw.title.getCurrentTitle

return p

and then save a page with this content:

{{#invoke:MyModule|myFunc}} {{#invoke:MyModule|myFunc2}} {{#invoke:MyModule|getCurrentTitle}}

Actual Results:
You will observe an error like:
Lua error in mw.lua at line 499: attempt to call field 'getCurrentFrame' (a nil value). (refers to this line of code)

Expected Results:
The output of the module should be the return the return value of those functions, with no error message.

Perhaps this is an undefined behavior or there was a breaking change that might need an announcement.

Event Timeline

I believe bug was introduced by the fix to T234368.

Change 545329 had a related patch set uploaded (by Anomie; owner: Anomie):
[mediawiki/extensions/Scribunto@master] Don't error if someone returns a built-in function from their module

https://gerrit.wikimedia.org/r/545329

Change 545329 merged by jenkins-bot:
[mediawiki/extensions/Scribunto@master] Don't error if someone returns a built-in function from their module

https://gerrit.wikimedia.org/r/545329

The fix should go out to Wikimedia wikis with 1.35.0-wmf.4 next week. See https://www.mediawiki.org/wiki/MediaWiki_1.35/Roadmap for a schedule.