https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114701
Revision: 114701
Author: tstarling
Date: 2012-04-04 05:10:47 +0000 (Wed, 04 Apr 2012)
Log Message:
-----------
* Added missing message scripting-exception-common-toofewargs
* In importModule(), don't catch exceptions since that luasandbox bug is fixed
now
* Use the chunkName parameter to loadString to get more informative error
messages
Modified Paths:
--------------
trunk/extensions/Scripting/engines/LuaSandbox/Engine.php
trunk/extensions/Scripting/i18n/Messages.php
Modified: trunk/extensions/Scripting/engines/LuaSandbox/Engine.php
===================================================================
--- trunk/extensions/Scripting/engines/LuaSandbox/Engine.php 2012-04-04
04:00:20 UTC (rev 114700)
+++ trunk/extensions/Scripting/engines/LuaSandbox/Engine.php 2012-04-04
05:10:47 UTC (rev 114701)
@@ -62,20 +62,15 @@
}
function importModule() {
- // FIXME: luasandbox segfaults on exceptions
- try {
- $args = func_get_args();
- if( count( $args ) < 1 ) {
- // FIXME: LuaSandbox PHP extension should
provide proper context
- throw new ScriptingException( 'toofewargs',
'common', null, null, array( 'mw.import' ) );
- }
-
- $module = $this->getModule( $args[0] );
- $module->initialize();
- return $module->mContents;
- } catch( ScriptingException $e ) {
- return null;
+ $args = func_get_args();
+ if( count( $args ) < 1 ) {
+ // FIXME: LuaSandbox PHP extension should provide
proper context
+ throw new ScriptingException( 'toofewargs', 'common',
null, null, array( 'mw.import' ) );
}
+
+ $module = $this->getModule( $args[0] );
+ $module->initialize();
+ return $module->mContents;
}
}
@@ -91,7 +86,10 @@
// FIXME: caching?
try {
- $this->mBody = $this->mEngine->mSandbox->loadString(
$this->mCode );
+ $this->mBody = $this->mEngine->mSandbox->loadString(
+ $this->mCode,
+ // Prepending an "@" to the chunk name makes
Lua think it is a file name
+ '@' . $this->getTitle()->getPrefixedDBkey() );
$output = $this->mBody->call();
} catch( LuaSandboxError $e ) {
throw new ScriptingException( 'error', 'luasandbox',
null, null, array( $e->getMessage() ) );
Modified: trunk/extensions/Scripting/i18n/Messages.php
===================================================================
--- trunk/extensions/Scripting/i18n/Messages.php 2012-04-04 04:00:20 UTC
(rev 114700)
+++ trunk/extensions/Scripting/i18n/Messages.php 2012-04-04 05:10:47 UTC
(rev 114701)
@@ -15,4 +15,5 @@
'scripting-desc' => 'Framework for embedding scripting languages into
MediaWiki pages',
'scripting-exception-luasandbox-error' => 'Lua error: $1',
+ 'scripting-exception-common-toofewargs' => 'Lua error: Too few
arguments to function $1',
);
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs