mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-24 00:05:00 +00:00
Don't error if someone returns a built-in function from their module
This is getting close to the point of "don't do that, just wrap the built-in". But since it's a regression in a recent patch, let's restore the old behavior here. Bug: T236092 Change-Id: Ieddc23d942bc91fd0246ae14d8a4af7719e3834f
This commit is contained in:
parent
de636b2bc6
commit
0ee41431c2
|
@ -496,7 +496,16 @@ function mw.executeModule( chunk, name, frame )
|
|||
end
|
||||
|
||||
function mw.executeFunction( chunk )
|
||||
local frame = getfenv( chunk ).mw.getCurrentFrame()
|
||||
local getCurrentFrame = getfenv( chunk ).mw.getCurrentFrame
|
||||
local frame
|
||||
if getCurrentFrame then
|
||||
-- Normal case
|
||||
frame = getCurrentFrame()
|
||||
else
|
||||
-- If someone assigns a built-in method to the module's return table,
|
||||
-- its env won't have mw.getCurrentFrame()
|
||||
frame = newFrame( 'current', 'parent' )
|
||||
end
|
||||
|
||||
if executeFunctionDepth == 0 then
|
||||
-- math.random is defined as using C's rand(), and C's rand() uses 1 as
|
||||
|
|
|
@ -811,6 +811,23 @@ class Scribunto_LuaCommonTest extends Scribunto_LuaEngineTestBase {
|
|||
$this->assertTrue( mb_check_encoding( $err, 'UTF-8' ), 'JS config vars are UTF-8' );
|
||||
}
|
||||
}
|
||||
|
||||
public function testT236092() {
|
||||
$engine = $this->getEngine();
|
||||
$parser = $engine->getParser();
|
||||
$pp = $parser->getPreprocessor();
|
||||
|
||||
$this->extraModules['Module:T236092'] = '
|
||||
local p = {}
|
||||
p.foo = mw.isSubsting
|
||||
return p
|
||||
';
|
||||
|
||||
$frame = $pp->newFrame();
|
||||
$text = $frame->expand( $pp->preprocessToObj( ">{{#invoke:T236092|foo}}<" ) );
|
||||
$text = $parser->mStripState->unstripBoth( $text );
|
||||
$this->assertSame( '>false<', $text );
|
||||
}
|
||||
}
|
||||
|
||||
class Scribunto_LuaCommonTestsLibrary extends Scribunto_LuaLibraryBase {
|
||||
|
|
Loading…
Reference in a new issue