MarkAHershberger has uploaded a new change for review. https://gerrit.wikimedia.org/r/75819
Change subject: Scribunto should error out sooner if lua isn't executable Improve error reporting by causing Scribunto to fail earlier if lua can't be run. ...................................................................... Scribunto should error out sooner if lua isn't executable Improve error reporting by causing Scribunto to fail earlier if lua can't be run. Change-Id: I43fb38c6c3facbd7b65b7ae16f1d23ee72f7a5ff Bug: 52002 --- M engines/LuaStandalone/LuaStandaloneEngine.php 1 file changed, 15 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Scribunto refs/changes/19/75819/1 diff --git a/engines/LuaStandalone/LuaStandaloneEngine.php b/engines/LuaStandalone/LuaStandaloneEngine.php index f656111..ddf6611 100644 --- a/engines/LuaStandalone/LuaStandaloneEngine.php +++ b/engines/LuaStandalone/LuaStandaloneEngine.php @@ -29,10 +29,10 @@ } $status = $this->interpreter->getStatus(); $lang = Language::factory( 'en' ); - return - 'Lua time usage: ' . sprintf( "%.3f", $status['time'] / $this->getClockTick() ) . "s\n" . - 'Lua virtual size: ' . - $lang->formatSize( $status['vsize'] ) . ' / ' . + return + 'Lua time usage: ' . sprintf( "%.3f", $status['time'] / $this->getClockTick() ) . "s\n" . + 'Lua virtual size: ' . + $lang->formatSize( $status['vsize'] ) . ' / ' . $lang->formatSize( $this->options['memoryLimit'] ) . "\n" . 'Lua estimated memory usage: ' . $lang->formatSize( $status['vsize'] - $this->initialStatus['vsize'] ) . "\n"; @@ -87,11 +87,15 @@ $path = 'lua5_1_5_mac_lion_fat_generic/lua'; } if ( $path === false ) { - throw new Scribunto_LuaInterpreterNotFoundError( + throw new Scribunto_LuaInterpreterNotFoundError( 'No Lua interpreter was given in the configuration, ' . 'and no bundled binary exists for this platform.' ); } $options['luaPath'] = dirname( __FILE__ ) . "/binaries/$path"; + + if( !is_executable( $options['luaPath'] ) ) { + throw new MWException( "lua is not executable: " . $options['luaPath'] ); + } } $this->engine = $engine; @@ -99,14 +103,14 @@ $pipes = null; $cmd = wfEscapeShellArg( - $options['luaPath'], + $options['luaPath'], dirname( __FILE__ ) . '/mw_main.lua', dirname( dirname( dirname( __FILE__ ) ) ) ); if ( php_uname( 's' ) == 'Linux' ) { // Limit memory and CPU $cmd = wfEscapeShellArg( '/bin/sh', - dirname( __FILE__ ) . '/lua_ulimit.sh', + dirname( __FILE__ ) . '/lua_ulimit.sh', $options['cpuLimit'], # soft limit (SIGXCPU) $options['cpuLimit'] + 1, # hard limit intval( $options['memoryLimit'] / 1024 ), @@ -121,11 +125,11 @@ // so we use the fix similar to one in wfShellExec() $cmd = '"' . $cmd . '"'; } - + wfDebug( __METHOD__.": creating interpreter: $cmd\n" ); $this->proc = proc_open( - $cmd, + $cmd, array( array( 'pipe', 'r' ), array( 'pipe', 'w' ), @@ -377,7 +381,7 @@ return $var; case 'string': return '"' . - strtr( $var, array( + strtr( $var, array( '"' => '\\"', '\\' => '\\\\', "\n" => '\\n', @@ -400,7 +404,7 @@ if ( $var instanceof Scribunto_LuaStandaloneInterpreterFunction ) { return 'chunks[' . intval( $var->id ) . ']'; } else { - throw new MWException( __METHOD__.': unable to convert object of type ' . + throw new MWException( __METHOD__.': unable to convert object of type ' . get_class( $var ) ); } case 'resource': -- To view, visit https://gerrit.wikimedia.org/r/75819 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I43fb38c6c3facbd7b65b7ae16f1d23ee72f7a5ff Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Scribunto Gerrit-Branch: master Gerrit-Owner: MarkAHershberger <mhershber...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits