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.

Details

Related Gerrit Patches:

Event Timeline

Restricted Application added subscribers: Liuxinyu970226, Aklapper. · View Herald TranscriptOct 21 2019, 5:06 PM
Pppery added a subscriber: Pppery.EditedOct 21 2019, 9:46 PM

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

Anomie claimed this task.Oct 22 2019, 4:43 PM

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

Pppery removed a subscriber: Pppery.Oct 23 2019, 11:43 AM
Anomie closed this task as Resolved.Oct 23 2019, 4:24 PM

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.