jenkins-bot has submitted this change and it was merged.

Change subject: Don't attempt to parse non-Modules in the console
......................................................................


Don't attempt to parse non-Modules in the console

When processing Lua console requests, don't attempt to parse pages that
aren't modules. This allows the Lua console to be successfully loaded
everywhere.

Change-Id: Idfd1985aca4acb6a8f3235d34ac00358e30e361c
---
M engines/LuaCommon/LuaCommon.php
1 file changed, 13 insertions(+), 6 deletions(-)

Approvals:
  Tim Starling: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/engines/LuaCommon/LuaCommon.php b/engines/LuaCommon/LuaCommon.php
index 7aa401a..d8467a4 100644
--- a/engines/LuaCommon/LuaCommon.php
+++ b/engines/LuaCommon/LuaCommon.php
@@ -331,8 +331,9 @@
                 * apparently that's what lua.c does.
                 */
                $code = "return function (__init, exe)\n" .
-                       "local _, p = exe(__init)\n" .
-                       "_, __init, exe = nil, nil, nil\n" .
+                       "if not exe then exe = function(...) return true, ... 
end end\n" .
+                       "local p = select(2, exe(__init) )\n" .
+                       "__init, exe = nil, nil\n" .
                        "local print = mw.log\n";
                foreach ( $params['prevQuestions'] as $q ) {
                        if ( substr( $q, 0, 1 ) === '=' ) {
@@ -353,9 +354,15 @@
                }
                $code .= "end\n";
 
-               $contentModule = $this->newModule(
-                       $params['content'], 
$params['title']->getPrefixedDBkey() );
-               $contentInit = $contentModule->getInitChunk();
+               if ( $params['title']->hasContentModel( 'Scribunto' ) ) {
+                       $contentModule = $this->newModule(
+                               $params['content'], 
$params['title']->getPrefixedDBkey() );
+                       $contentInit = $contentModule->getInitChunk();
+                       $contentExe = $this->mw['executeModule'];
+               } else {
+                       $contentInit = $params['content'];
+                       $contentExe = null;
+               }
 
                $consoleModule = $this->newModule(
                        $code,
@@ -364,7 +371,7 @@
                $consoleInit = $consoleModule->getInitChunk();
                $ret = $this->getInterpreter()->callFunction( 
$this->mw['executeModule'], $consoleInit, false );
                $func = $ret[1];
-               $ret = $this->getInterpreter()->callFunction( $func, 
$contentInit, $this->mw['executeModule'] );
+               $ret = $this->getInterpreter()->callFunction( $func, 
$contentInit, $contentExe );
 
                return array(
                        'return' => isset( $ret[0] ) ? $ret[0] : null,

-- 
To view, visit https://gerrit.wikimedia.org/r/124473
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Idfd1985aca4acb6a8f3235d34ac00358e30e361c
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Scribunto
Gerrit-Branch: master
Gerrit-Owner: Jackmcbarn <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to