2012-01-28 16:22:18 +00:00
|
|
|
<?php
|
|
|
|
|
2017-06-24 00:53:28 +00:00
|
|
|
if ( function_exists( 'wfLoadExtension' ) ) {
|
|
|
|
wfLoadExtension( 'Scribunto' );
|
|
|
|
// Keep i18n globals so mergeMessageFileList.php doesn't break
|
|
|
|
$wgMessagesDirs['Scribunto'] = __DIR__ . '/i18n';
|
|
|
|
$wgExtensionMessagesFiles['ScribuntoMagic'] = __DIR__ . '/Scribunto.magic.php';
|
|
|
|
$wgExtensionMessagesFiles['ScribuntoNamespaces'] = __DIR__ . '/Scribunto.namespaces.php';
|
|
|
|
/* wfWarn(
|
|
|
|
'Deprecated PHP entry point used for Scribunto extension. Please use wfLoadExtension instead,' .
|
|
|
|
' see https://www.mediawiki.org/wiki/Extension_registration for more details.'
|
|
|
|
); */
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
die( 'This version of the Scribunto extension requires MediaWiki 1.27+' );
|
2016-05-17 14:52:05 +00:00
|
|
|
}
|
2012-01-28 16:22:18 +00:00
|
|
|
|
2017-06-24 00:53:28 +00:00
|
|
|
/**
|
|
|
|
* The rest of this file is a PHP stub for providing documentation
|
|
|
|
* about the various configuration settings for Scribunto, as well
|
|
|
|
* as providing hints for IDEs. It is not executed by MediaWiki.
|
|
|
|
*/
|
2012-01-28 16:22:18 +00:00
|
|
|
|
|
|
|
/**
|
2012-04-06 05:04:30 +00:00
|
|
|
* The name of the default script engine.
|
2012-01-28 16:22:18 +00:00
|
|
|
*/
|
Added more Lua environment features
Package library:
* Added a simulation of the Lua 5.1 package library.
* Removed mw.import(), replaced it with a package loader. Packages can be
retrieved from the wiki, using require('Module:Foo'), or from files
distributed with Scribunto, using require('foo'). The "Module:" prefix allows
for source compatibility with existing Lua code.
* Added a couple of libraries from LuaForge: luabit and stringtools.
* Made fetchModuleFromParser() return null on error instead of throwing an
exception, to more easily support the desired behaviour of the package loader,
which needs to return null on error.
* Renamed mw.setupEnvironment() to mw.setup() since it is setting up things
other than the environment now.
* In MWServer:handleRegisterLibrary(), remove the feature which interprets dots
in library names, since LuaSandbox doesn't support this.
Improved module isolation and related refactoring:
* Expose restricted versions of getfenv() and setfenv() to user Lua code.
Requires luasandbox r114952.
* Don't cache the export list returned by module execution for later function
calls. This breaks isolation of #invoke calls, since the local variables are
persistent.
* Removed ScribuntoFunctionBase and its children, since it doesn't really have
a purpose if it can't cache anything. Instead, invoke functions using a module
method called invoke().
* Removed Module::initialize(), replaced it with a validate() function. This is
a more elegant interface and works better with the new module caching scheme.
* Use a Status object for the return value of Engine::validate() instead of an
array. Use the formatting facilities of the Status class.
Other:
* Removed "too many returns" error, doesn't fit in with Lua conventions.
* Use the standalone engine by default, so that the extension will work without
configuration for more people.
* Added an accessor for $engine->interpreter
* Fix mw.clone() to correctly clone metatables
* If the standalone interpreter exits due to an error, there are some contexts
where the initial error will be caught and ignored, and the user will see the
error from checkValid() instead. In this case, rethrow the original error for
a more informative message.
* Load mw.lua into the initial standalone environment, to reduce code
duplication between mw.lua and MWServer.lua.
* Fixed a bug in Scribunto_LuaStandaloneInterpreter::handleCall() for functions
that return no results.
* Fixed a bug in encodeLuaVar() for strings with "\r". Added test case.
* In MWServer.lua, don't call error() for internal errors, instead just print
the error and exit. This avoids a protocol violation when an error is
encountered from within handleCall().
* Added lots of documentation. Lua doc comments are in LuaDoc format.
Change-Id: Ie2fd572c362bedf02f45d3fa5352a5280e034740
2012-04-18 03:46:18 +00:00
|
|
|
$wgScribuntoDefaultEngine = 'luastandalone';
|
2012-01-28 16:22:18 +00:00
|
|
|
|
2012-04-05 07:58:02 +00:00
|
|
|
/**
|
2012-04-06 05:04:30 +00:00
|
|
|
* Configuration for each script engine
|
2012-04-05 07:58:02 +00:00
|
|
|
*/
|
2017-06-15 17:19:00 +00:00
|
|
|
$wgScribuntoEngineConf = [
|
|
|
|
'luasandbox' => [
|
2012-04-13 10:38:12 +00:00
|
|
|
'class' => 'Scribunto_LuaSandboxEngine',
|
|
|
|
'memoryLimit' => 50 * 1024 * 1024,
|
|
|
|
'cpuLimit' => 7,
|
2012-05-23 06:51:59 +00:00
|
|
|
|
2012-12-27 23:26:06 +00:00
|
|
|
// The profiler sample period, or false to disable the profiler
|
|
|
|
'profilerPeriod' => 0.02,
|
|
|
|
|
2012-09-25 07:58:42 +00:00
|
|
|
// Set this to true to allow setfenv() and getfenv() in user code.
|
2014-03-28 20:46:41 +00:00
|
|
|
// Note that these functions have been removed in Lua 5.2. Scribunto
|
|
|
|
// does not yet support Lua 5.2, but we expect support will be
|
|
|
|
// implemented in the future, and there is no guarantee that a
|
2012-05-23 06:51:59 +00:00
|
|
|
// simulation of setfenv() and getfenv() will be provided.
|
|
|
|
'allowEnvFuncs' => false,
|
2017-03-20 02:59:23 +00:00
|
|
|
|
|
|
|
// The maximum number of languages about which data can be requested.
|
|
|
|
// The cost is about 1.5MB of memory usage per language on default
|
|
|
|
// installations (during recache), but if recaching is disabled with
|
|
|
|
// $wgLocalisationCacheConf['manualRecache'] = false
|
|
|
|
// then memory usage is perhaps 10x smaller.
|
|
|
|
'maxLangCacheSize' => 30,
|
2017-06-15 17:19:00 +00:00
|
|
|
],
|
|
|
|
'luastandalone' => [
|
2012-04-13 10:38:12 +00:00
|
|
|
'class' => 'Scribunto_LuaStandaloneEngine',
|
|
|
|
|
|
|
|
// A filename to act as the destination for stderr from the Lua
|
2014-03-28 20:46:41 +00:00
|
|
|
// binary. This may provide useful error information if Lua fails to
|
2012-04-13 10:38:12 +00:00
|
|
|
// run. Set this to null to discard stderr output.
|
|
|
|
'errorFile' => null,
|
|
|
|
|
|
|
|
// The location of the Lua binary, or null to use the bundled binary.
|
|
|
|
'luaPath' => null,
|
2012-04-05 07:58:02 +00:00
|
|
|
'memoryLimit' => 50 * 1024 * 1024,
|
|
|
|
'cpuLimit' => 7,
|
2012-05-23 06:51:59 +00:00
|
|
|
'allowEnvFuncs' => false,
|
2017-03-20 02:59:23 +00:00
|
|
|
'maxLangCacheSize' => 30,
|
2017-06-15 17:19:00 +00:00
|
|
|
],
|
|
|
|
];
|
2012-01-28 16:22:18 +00:00
|
|
|
|
|
|
|
/**
|
2012-05-22 03:56:07 +00:00
|
|
|
* Set to true to enable the SyntaxHighlight_GeSHi extension
|
2012-01-28 16:22:18 +00:00
|
|
|
*/
|
2012-04-06 05:04:30 +00:00
|
|
|
$wgScribuntoUseGeSHi = false;
|
2012-01-28 16:22:18 +00:00
|
|
|
|
2012-02-06 22:14:47 +00:00
|
|
|
/**
|
2012-05-22 03:56:07 +00:00
|
|
|
* Set to true to enable the CodeEditor extension
|
2012-02-06 22:14:47 +00:00
|
|
|
*/
|
2012-04-06 05:04:30 +00:00
|
|
|
$wgScribuntoUseCodeEditor = false;
|
2012-02-06 22:14:47 +00:00
|
|
|
|
2015-10-24 23:54:11 +00:00
|
|
|
/**
|
|
|
|
* Set to true to enable gathering and reporting of performance data
|
|
|
|
* for slow function invocations.
|
|
|
|
*/
|
|
|
|
$wgScribuntoGatherFunctionStats = false;
|
|
|
|
|
2015-10-29 22:53:10 +00:00
|
|
|
/**
|
|
|
|
* If $wgScribuntoGatherFunctionStats is true, this variable specifies
|
|
|
|
* the percentile threshold for slow function invocations. Should be
|
|
|
|
* a value between 0 and 1 (exclusive).
|
|
|
|
*/
|
|
|
|
$wgScribuntoSlowFunctionThreshold = 0.90;
|
|
|
|
|