mediawiki-extensions-Scribunto/Scribunto.php

100 lines
3.1 KiB
PHP
Raw Normal View History

<?php
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.31+' );
}
/**
* 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.
*/
define( 'NS_MODULE', 828 );
define( 'NS_MODULE_TALK', 829 );
/**
2012-04-06 05:04:30 +00:00
* The name of the default script engine.
*/
$wgScribuntoDefaultEngine = 'luaautodetect';
* Removed scriptlinks table. It just seemed the same as templatelinks to me, and tl_namespace can be used if you want to separate out modules. * Used Parser::fetchTemplateAndTitle() to get modules and register them in templatelinks. Most of the logic was previously duplicated. * Changed the configuration and factory functions to allow for the possibility of multiple engines coexisting on the one wiki. * Made the $parser parameter optional, to improve debugging in the case where a parser is needed but parsing has not started. Removed all $wgParser references. * Renamed Scripting::getEngine() to getParserEngine() and resetEngine() to resetParserEngine() * Removed setOptions() and updateOptions(). If you want to change the options, you can always make a new instance. * Renamed getModule() to fetchModuleFromParser() * Simplified module constructor parameters and member variable list * Fixed spelling error langauge -> language * Renamed a few variables for clarity: $module -> $moduleName, $function -> $functionName * Renamed getLimitsReport() to getLimitReport() as it is in Parser * Use an accessor for getting LuaSandboxEngineModule::$contents * Renamed configuration variable maxCPU to cpuLimit * Include the full message name as a parameter to ScriptingException. This makes it easier to find messages in the i18n file, and it makes it easier to find invocation points when a translator wants to know how a message is used. Adding the message name as a comment on the same line seems like a waste of space when you can just make it an actual parameter. * Reduce the number of formal parameters to ScriptingException::__construct(), since there is already too many and we may want to add more things later, such as backtraces with hyperlinks and other such stuff. * Include the code location as $2 unconditionally so that there is less chance of getting the parameters wrong * Shortened some message names. Wrote English text for messages without it.
2012-04-05 07:58:02 +00:00
/**
2012-04-06 05:04:30 +00:00
* Configuration for each script engine
* Removed scriptlinks table. It just seemed the same as templatelinks to me, and tl_namespace can be used if you want to separate out modules. * Used Parser::fetchTemplateAndTitle() to get modules and register them in templatelinks. Most of the logic was previously duplicated. * Changed the configuration and factory functions to allow for the possibility of multiple engines coexisting on the one wiki. * Made the $parser parameter optional, to improve debugging in the case where a parser is needed but parsing has not started. Removed all $wgParser references. * Renamed Scripting::getEngine() to getParserEngine() and resetEngine() to resetParserEngine() * Removed setOptions() and updateOptions(). If you want to change the options, you can always make a new instance. * Renamed getModule() to fetchModuleFromParser() * Simplified module constructor parameters and member variable list * Fixed spelling error langauge -> language * Renamed a few variables for clarity: $module -> $moduleName, $function -> $functionName * Renamed getLimitsReport() to getLimitReport() as it is in Parser * Use an accessor for getting LuaSandboxEngineModule::$contents * Renamed configuration variable maxCPU to cpuLimit * Include the full message name as a parameter to ScriptingException. This makes it easier to find messages in the i18n file, and it makes it easier to find invocation points when a translator wants to know how a message is used. Adding the message name as a comment on the same line seems like a waste of space when you can just make it an actual parameter. * Reduce the number of formal parameters to ScriptingException::__construct(), since there is already too many and we may want to add more things later, such as backtraces with hyperlinks and other such stuff. * Include the code location as $2 unconditionally so that there is less chance of getting the parameters wrong * Shortened some message names. Wrote English text for messages without it.
2012-04-05 07:58:02 +00:00
*/
$wgScribuntoEngineConf = [
'luasandbox' => [
'class' => 'Scribunto_LuaSandboxEngine',
'memoryLimit' => 50 * 1024 * 1024,
'cpuLimit' => 7,
// The profiler sample period, or false to disable the profiler
'profilerPeriod' => 0.02,
// Set this to true to allow setfenv() and getfenv() in user code.
// 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
// simulation of setfenv() and getfenv() will be provided.
'allowEnvFuncs' => false,
// 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,
],
'luastandalone' => [
'class' => 'Scribunto_LuaStandaloneEngine',
// A filename to act as the destination for stderr from the Lua
// binary. This may provide useful error information if Lua fails to
// 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,
* Removed scriptlinks table. It just seemed the same as templatelinks to me, and tl_namespace can be used if you want to separate out modules. * Used Parser::fetchTemplateAndTitle() to get modules and register them in templatelinks. Most of the logic was previously duplicated. * Changed the configuration and factory functions to allow for the possibility of multiple engines coexisting on the one wiki. * Made the $parser parameter optional, to improve debugging in the case where a parser is needed but parsing has not started. Removed all $wgParser references. * Renamed Scripting::getEngine() to getParserEngine() and resetEngine() to resetParserEngine() * Removed setOptions() and updateOptions(). If you want to change the options, you can always make a new instance. * Renamed getModule() to fetchModuleFromParser() * Simplified module constructor parameters and member variable list * Fixed spelling error langauge -> language * Renamed a few variables for clarity: $module -> $moduleName, $function -> $functionName * Renamed getLimitsReport() to getLimitReport() as it is in Parser * Use an accessor for getting LuaSandboxEngineModule::$contents * Renamed configuration variable maxCPU to cpuLimit * Include the full message name as a parameter to ScriptingException. This makes it easier to find messages in the i18n file, and it makes it easier to find invocation points when a translator wants to know how a message is used. Adding the message name as a comment on the same line seems like a waste of space when you can just make it an actual parameter. * Reduce the number of formal parameters to ScriptingException::__construct(), since there is already too many and we may want to add more things later, such as backtraces with hyperlinks and other such stuff. * Include the code location as $2 unconditionally so that there is less chance of getting the parameters wrong * Shortened some message names. Wrote English text for messages without it.
2012-04-05 07:58:02 +00:00
'memoryLimit' => 50 * 1024 * 1024,
'cpuLimit' => 7,
'allowEnvFuncs' => false,
'maxLangCacheSize' => 30,
],
'luaautodetect' => [
'factory' => 'Scribunto_LuaEngine::newAutodetectEngine',
],
];
/**
2012-05-22 03:56:07 +00:00
* Set to true to enable the SyntaxHighlight_GeSHi extension
*/
$wgScribuntoUseGeSHi = true;
/**
2012-05-22 03:56:07 +00:00
* Set to true to enable the CodeEditor extension
*/
$wgScribuntoUseCodeEditor = true;
/**
* Set to true to enable gathering and reporting of performance data
* for slow function invocations.
*/
$wgScribuntoGatherFunctionStats = false;
/**
* 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;