Page MenuHomePhabricator

mw.loadData can be used to pass data between #invoke's by reading frame arguments
Closed, ResolvedPublic

Description

Create the following as Module:LoadData/data:
return { mw.getCurrentFrame().args[1] }

Create the following as Module:LoadData:
local p = {}
function p.main(frame)
return mw.loadData('Module:LoadData/data')[1]
end
return p

Create the following as Module:LoadData/doc:
{{#invoke:LoadData|main|some data to share}}
{{#invoke:LoadData|main}}
{{#invoke:LoadData|main}}

This will return the following:
some data to share
some data to share
some data to share

This indicates a break of isolation between the different calls to #invoke.


Version: unspecified
Severity: major

Details

Reference
bz65687

Event Timeline

bzimport raised the priority of this task from to High.
bzimport set Reference to bz65687.

Ugh.

Inside mw.loadData, we should have mw.getCurrentFrame() return a frame with no args and no parent, and probably either nil or the name of the module passed to mw.loadData for getTitle(). Can you think of any other fields in the frame that would be problematic?

That sounds like it should be good, but could any games be played with newChild and/or getParent to defeat that?

(Specifically, mw.getCurrentFrame():newChild{blah blah...}:getParent() is what I'm worried about leaking the "real" current frame.)

(In reply to Jackmcbarn from comment #3)

(Specifically, mw.getCurrentFrame():newChild{blah blah...}:getParent() is
what I'm worried about leaking the "real" current frame.)

No, that'd return the same as mw.getCurrentFrame(). There's a test for this in Scribunto_LuaCommonTests::testFrames().

I'm saying that when this is changed, that test should also happen within a loadData environment, to make sure it doesn't get inadvertently broken in that case.

Change 144478 had a related patch set uploaded by Anomie:
Improve mw.getCurrentFrame handling

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

Change 144478 merged by jenkins-bot:
Improve mw.getCurrentFrame handling

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

Change 144511 had a related patch set uploaded by Jackmcbarn:
Improve mw.getCurrentFrame handling

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

Change 144511 merged by jenkins-bot:
Improve mw.getCurrentFrame handling

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