MtDu has uploaded a new change for review. https://gerrit.wikimedia.org/r/265184
Change subject: Convert Scribunto to use new registration ...................................................................... Convert Scribunto to use new registration Bug: T87969 Change-Id: Id00a2a00bddf72f5c8716f21226695456b3a32c6 --- A Scribunto.hooks.php D Scribunto.i18n.php M Scribunto.php A extension.json 4 files changed, 202 insertions(+), 240 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Scribunto refs/changes/84/265184/1 diff --git a/Scribunto.hooks.php b/Scribunto.hooks.php new file mode 100644 index 0000000..136e6be --- /dev/null +++ b/Scribunto.hooks.php @@ -0,0 +1,9 @@ +<?php +class ScribuntoHooks { + + public static function registerExtension() { + define( 'CONTENT_MODEL_SCRIBUNTO', 'Scribunto' ); + define( 'NS_MODULE', 828 ); + define( 'NS_MODULE_TALK', 829 ); + } +} diff --git a/Scribunto.i18n.php b/Scribunto.i18n.php deleted file mode 100644 index 5b59e71..0000000 --- a/Scribunto.i18n.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php -/** - * This is a backwards-compatibility shim, generated by: - * https://git.wikimedia.org/blob/mediawiki%2Fcore.git/HEAD/maintenance%2FgenerateJsonI18n.php - * - * Beginning with MediaWiki 1.23, translation strings are stored in json files, - * and the EXTENSION.i18n.php file only exists to provide compatibility with - * older releases of MediaWiki. For more information about this migration, see: - * https://www.mediawiki.org/wiki/Requests_for_comment/Localisation_format - * - * This shim maintains compatibility back to MediaWiki 1.17. - */ -$messages = array(); -if ( !function_exists( 'wfJsonI18nShimc5d9278c8d74fbc1' ) ) { - function wfJsonI18nShimc5d9278c8d74fbc1( $cache, $code, &$cachedData ) { - $codeSequence = array_merge( array( $code ), $cachedData['fallbackSequence'] ); - foreach ( $codeSequence as $csCode ) { - $fileName = dirname( __FILE__ ) . "/i18n/$csCode.json"; - if ( is_readable( $fileName ) ) { - $data = FormatJson::decode( file_get_contents( $fileName ), true ); - foreach ( array_keys( $data ) as $key ) { - if ( $key === '' || $key[0] === '@' ) { - unset( $data[$key] ); - } - } - $cachedData['messages'] = array_merge( $data, $cachedData['messages'] ); - } - - $cachedData['deps'][] = new FileDependency( $fileName ); - } - return true; - } - - $GLOBALS['wgHooks']['LocalisationCacheRecache'][] = 'wfJsonI18nShimc5d9278c8d74fbc1'; -} diff --git a/Scribunto.php b/Scribunto.php index 49961cf..07c33cc 100644 --- a/Scribunto.php +++ b/Scribunto.php @@ -1,206 +1,15 @@ <?php -/** - * Wikitext scripting infrastructure for MediaWiki. - * Copyright (C) 2009-2012 Victor Vasiliev <vasi...@gmail.com> - * http://www.mediawiki.org/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - */ - -if ( !defined( 'MEDIAWIKI' ) ) - die(); - -$wgExtensionCredits['parserhook']['Scribunto'] = array( - 'path' => __FILE__, - 'name' => 'Scribunto', - 'author' => array( 'Victor Vasiliev', 'Tim Starling', 'Brad Jorsch' ), - 'descriptionmsg' => 'scribunto-desc', - 'url' => 'https://www.mediawiki.org/wiki/Extension:Scribunto', -); - -define( 'CONTENT_MODEL_SCRIBUNTO', 'Scribunto' ); - -$dir = __DIR__ . '/'; -$wgMessagesDirs['Scribunto'] = __DIR__ . '/i18n'; -$wgExtensionMessagesFiles['Scribunto'] = $dir . 'Scribunto.i18n.php'; -$wgExtensionMessagesFiles['ScribuntoMagic'] = $dir . 'Scribunto.magic.php'; -$wgExtensionMessagesFiles['ScribuntoNamespaces'] = $dir . 'Scribunto.namespaces.php'; - -$wgAutoloadClasses['ScribuntoEngineBase'] = $dir.'common/Base.php'; -$wgAutoloadClasses['ScribuntoModuleBase'] = $dir.'common/Base.php'; -$wgAutoloadClasses['ScribuntoHooks'] = $dir.'common/Hooks.php'; -$wgAutoloadClasses['ScribuntoException'] = $dir.'common/Common.php'; -$wgAutoloadClasses['Scribunto'] = $dir.'common/Common.php'; -$wgAutoloadClasses['ApiScribuntoConsole'] = $dir.'common/ApiScribuntoConsole.php'; -$wgAutoloadClasses['ScribuntoContentHandler'] = $dir.'common/ScribuntoContentHandler.php'; -$wgAutoloadClasses['ScribuntoContent'] = $dir.'common/ScribuntoContent.php'; -$wgAutoloadClasses['Scribunto_LuaError'] = $dir.'engines/LuaCommon/LuaCommon.php'; -$wgAutoloadClasses['Scribunto_LuaInterpreterNotFoundError'] = $dir.'engines/LuaCommon/LuaInterpreter.php'; -$wgAutoloadClasses['Scribunto_LuaSandboxInterpreter'] = $dir.'engines/LuaSandbox/Engine.php'; -$wgAutoloadClasses['Scribunto_LuaSandboxCallback'] = $dir.'engines/LuaSandbox/Engine.php'; -$wgAutoloadClasses['Scribunto_LuaStandaloneInterpreterFunction'] = $dir.'engines/LuaStandalone/LuaStandaloneEngine.php'; -$wgAutoloadClasses['Scribunto_LuaEngineTestSkip'] = $dir.'tests/engines/LuaCommon/LuaEngineTestBase.php'; - -$wgHooks['SoftwareInfo'][] = 'ScribuntoHooks::getSoftwareInfo'; - -$wgHooks['ParserFirstCallInit'][] = 'ScribuntoHooks::setupParserHook'; -$wgHooks['ParserLimitReport']['scribunto'] = 'ScribuntoHooks::reportLimits'; -$wgHooks['ParserLimitReportPrepare'][] = 'ScribuntoHooks::reportLimitData'; -$wgHooks['ParserLimitReportFormat'][] = 'ScribuntoHooks::formatLimitData'; -$wgHooks['ParserClearState'][] = 'ScribuntoHooks::clearState'; -$wgHooks['ParserCloned'][] = 'ScribuntoHooks::parserCloned'; - -$wgHooks['CanonicalNamespaces'][] = 'ScribuntoHooks::addCanonicalNamespaces'; -$wgHooks['CodeEditorGetPageLanguage'][] = 'ScribuntoHooks::getCodeLanguage'; -$wgHooks['EditPageBeforeEditChecks'][] = 'ScribuntoHooks::beforeEditChecks'; -$wgHooks['EditPage::showReadOnlyForm:initial'][] = 'ScribuntoHooks::showReadOnlyFormInitial'; -$wgHooks['EditPageBeforeEditButtons'][] = 'ScribuntoHooks::beforeEditButtons'; -$wgHooks['EditFilterMerged'][] = 'ScribuntoHooks::validateScript'; -$wgHooks['ArticleViewHeader'][] = 'ScribuntoHooks::showDocPageHeader'; -$wgHooks['ContentHandlerDefaultModelFor'][] = 'ScribuntoHooks::contentHandlerDefaultModelFor'; - -$wgHooks['UnitTestsList'][] = 'ScribuntoHooks::unitTestsList'; -$wgParserTestFiles[] = $dir . 'tests/engines/LuaCommon/luaParserTests.txt'; - -$wgContentHandlers[CONTENT_MODEL_SCRIBUNTO] = 'ScribuntoContentHandler'; - -$sbtpl = array( - 'localBasePath' => dirname( __FILE__ ) . '/modules', - 'remoteExtPath' => 'Scribunto/modules', -); - -$wgResourceModules['ext.scribunto.errors'] = $sbtpl + array( - 'scripts' => 'ext.scribunto.errors.js', - 'styles' => 'ext.scribunto.errors.css', - 'dependencies' => array( 'jquery.ui.dialog' ), - 'messages' => array( - 'scribunto-parser-dialog-title' - ), -); -$wgResourceModules['ext.scribunto.logs'] = $sbtpl + array( - 'styles' => 'ext.scribunto.logs.css', - 'position' => 'top', -); -$wgResourceModules['ext.scribunto.edit'] = $sbtpl + array( - 'scripts' => 'ext.scribunto.edit.js', - 'styles' => 'ext.scribunto.edit.css', - 'dependencies' => array( 'mediawiki.api', 'jquery.spinner' ), - 'messages' => array( - 'scribunto-console-title', - 'scribunto-console-intro', - 'scribunto-console-clear', - 'scribunto-console-cleared', - 'scribunto-console-cleared-session-lost', - ), -); -$wgAPIModules['scribunto-console'] = 'ApiScribuntoConsole'; - -/***** Individual engines and their configurations *****/ - -$wgAutoloadClasses['Scribunto_LuaEngine'] = $dir.'engines/LuaCommon/LuaCommon.php'; -$wgAutoloadClasses['Scribunto_LuaModule'] = $dir.'engines/LuaCommon/LuaCommon.php'; -$wgAutoloadClasses['Scribunto_LuaInterpreter'] = $dir.'engines/LuaCommon/LuaInterpreter.php'; -$wgAutoloadClasses['Scribunto_LuaSandboxEngine'] = $dir.'engines/LuaSandbox/Engine.php'; -$wgAutoloadClasses['Scribunto_LuaStandaloneEngine'] = $dir.'engines/LuaStandalone/LuaStandaloneEngine.php'; -$wgAutoloadClasses['Scribunto_LuaStandaloneInterpreter'] = $dir.'engines/LuaStandalone/LuaStandaloneEngine.php'; - -/***** Individual libraries and their configurations *****/ -$wgAutoloadClasses['Scribunto_LuaLibraryBase'] = $dir.'engines/LuaCommon/LibraryBase.php'; -$wgAutoloadClasses['Scribunto_LuaEngineTestBase'] = $dir.'tests/engines/LuaCommon/LuaEngineTestBase.php'; -$wgAutoloadClasses['Scribunto_LuaDataProvider'] = $dir.'tests/engines/LuaCommon/LuaDataProvider.php'; -$wgAutoloadClasses['Scribunto_LuaSiteLibrary'] = $dir.'engines/LuaCommon/SiteLibrary.php'; -$wgAutoloadClasses['Scribunto_LuaUriLibrary'] = $dir.'engines/LuaCommon/UriLibrary.php'; -$wgAutoloadClasses['Scribunto_LuaUstringLibrary'] = $dir.'engines/LuaCommon/UstringLibrary.php'; -$wgAutoloadClasses['Scribunto_LuaLanguageLibrary'] = $dir.'engines/LuaCommon/LanguageLibrary.php'; -$wgAutoloadClasses['Scribunto_LuaMessageLibrary'] = $dir.'engines/LuaCommon/MessageLibrary.php'; -$wgAutoloadClasses['Scribunto_LuaTitleLibrary'] = $dir.'engines/LuaCommon/TitleLibrary.php'; -$wgAutoloadClasses['Scribunto_LuaTextLibrary'] = $dir.'engines/LuaCommon/TextLibrary.php'; -$wgAutoloadClasses['Scribunto_LuaHtmlLibrary'] = $dir.'engines/LuaCommon/HtmlLibrary.php'; - -/***** Configuration *****/ - -/** - * The name of the default script engine. - */ -$wgScribuntoDefaultEngine = 'luastandalone'; - -/** - * Configuration for each script engine - */ -$wgScribuntoEngineConf = array( - 'luasandbox' => array( - '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, - ), - 'luastandalone' => array( - '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, - 'memoryLimit' => 50 * 1024 * 1024, - 'cpuLimit' => 7, - 'allowEnvFuncs' => false, - ), -); - -/** - * Set to true to enable the SyntaxHighlight_GeSHi extension - */ -$wgScribuntoUseGeSHi = false; - -/** - * Set to true to enable the CodeEditor extension - */ -$wgScribuntoUseCodeEditor = false; - -/** - * 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; - -define( 'NS_MODULE', 828 ); -define( 'NS_MODULE_TALK', 829 ); - -// Set subpages by default -$wgNamespacesWithSubpages[NS_MODULE] = true; -$wgNamespacesWithSubpages[NS_MODULE_TALK] = true; - -$wgTrackingCategories[] = 'scribunto-common-error-category'; -$wgTrackingCategories[] = 'scribunto-module-with-errors-category'; +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; +} else { + die( 'This version of the Scribunto extension requires MediaWiki 1.25+' ); +} diff --git a/extension.json b/extension.json new file mode 100644 index 0000000..d332c34 --- /dev/null +++ b/extension.json @@ -0,0 +1,179 @@ +{ + "name": "Scribunto", + "author": [ + "Victor Vasiliev", + "Tim Starling", + "Brad Jorsch" + ], + "descriptonmsg": "scribunto-desc", + "url": "https://www.mediawiki.org/wiki/Extension:Scribunto", + "callback": "ScribuntoHooks::registerExtension", + "MessageDirs": { + "Scribunto": [ + "i18n" + ] + }, + "ExtensionMessageFiles": { + "ScribuntoMagic": "Scribunto.magic.php", + "ScribuntoNamespaces": "Scribunto.namespaces.php" + }, + "AutoloadClasses": { + "ScribuntoEngineBase": "common/Base.php", + "ScribuntoModuleBase": "common/Base.php", + "ScribuntoHooks": "common/Hooks.php", + "ScribuntoException": "common/Common.php", + "Scribunto": "common/Common.php", + "ApiScribuntoConsole": "common/ApiScribuntoConsole.php", + "ScribuntoContentHandler": "common/ScribuntoContentHandler.php", + "ScribuntoContent": "common/ScribuntoContent.php", + "Scribunto_LuaError": "engines/LuaCommon/LuaCommon.php", + "Scribunto_LuaInterpreterNotFoundError": "engines/LuaCommon/LuaInterpreter.php", + "Scribunto_LuaSandboxInterpreter": "engines/LuaSandbox/Engine.php", + "Scribunto_LuaSandboxCallback": "engines/LuaSandbox/Engine.php", + "Scribunto_LuaStandaloneInterpreterFunction": "engines/LuaStandalone/LuaStandaloneEngine.php", + "Scribunto_LuaEngineTestSkip": "tests/engines/LuaCommon/LuaEngineTestBase.php", + "Scribunto_LuaEngine": "engines/LuaCommon/LuaCommon.php", + "Scribunto_LuaModule": "engines/LuaCommon/LuaCommon.php", + "Scribunto_LuaInterpreter": "engines/LuaCommon/LuaInterpreter.php", + "Scribunto_LuaSandboxEngine": "engines/LuaSandbox/Engine.php", + "Scribunto_LuaStandaloneEngine": "engines/LuaStandalone/LuaStandaloneEngine.php", + "Scribunto_LuaStandaloneInterpreter": "engines/LuaStandalone/LuaStandaloneEngine.php", + "Scribunto_LuaLibraryBase": "engines/LuaCommon/LibraryBase.php", + "Scribunto_LuaEngineTestBase": "tests/engines/LuaCommon/LuaEngineTestBase.php", + "Scribunto_LuaDataProvider": "tests/engines/LuaCommon/LuaDataProvider.php", + "Scribunto_LuaSiteLibrary": "engines/LuaCommon/SiteLibrary.php", + "Scribunto_LuaUriLibrary": "engines/LuaCommon/UriLibrary.php", + "Scribunto_LuaUstringLibrary": "engines/LuaCommon/UstringLibrary.php", + "Scribunto_LuaLanguageLibrary": "engines/LuaCommon/LanguageLibrary.php", + "Scribunto_LuaMessageLibrary": "engines/LuaCommon/MessageLibrary.php", + "Scribunto_LuaTitleLibrary": "engines/LuaCommon/TitleLibrary.php", + "Scribunto_LuaTextLibrary": "engines/LuaCommon/TextLibrary.php", + "Scribunto_LuaHtmlLibrary": "engines/LuaCommon/HtmlLibrary.php" + }, + "Hooks": { + "SoftwareInfo": [ + "ScribuntoHooks::getSoftwareInfo" + ], + "ParserFirstCallInit": [ + "ScribuntoHooks::setupParserHook" + ], + "ParserLimitReport": { + "scribunto": [ + "ScribuntoHooks::reportLimits" + ] + }, + "ParserLimitReportPrepare": [ + "ScribuntoHooks::reportLimitData" + ], + "ParserLimitReportFormat": [ + "ScribuntoHooks::formatLimitData" + ], + "ParserClearState": [ + "ScribuntoHooks::clearState" + ], + "ParserCloned": [ + "ScribuntoHooks::parserCloned" + ], + "CanonicalNamespaces": [ + "ScribuntoHooks::addCanonicalNamespaces" + ], + "CodeEditorGetPageLanguage": [ + "ScribuntoHooks::getCodeLanguage" + ], + "EditPageBeforeEditChecks": [ + "ScribuntoHooks::beforeEditChecks" + ], + "EditPage::showReadOnlyForm:initial": [ + "ScribuntoHooks::showReadOnlyFormInitial" + ], + "EditPageBeforeEditButtons": [ + "ScribuntoHooks::beforeEditButtons" + ], + "EditFilterMerged": [ + "ScribuntoHooks::validateScript" + ], + "ArticleViewHeader": [ + "ScribuntoHooks::showDocPageHeader" + ], + "ContentHandlerDefaultModelFor": [ + "ScribuntoHooks::contentHandlerDefaultModelFor" + ], + "UnitTestsList": [ + "ScribuntoHooks::unitTestsList" + ] + }, + "ParserTestFiles": "tests/engines/LuaCommon/luaParserTests.txt", + "ContentHandlers": { + "Scribunto": "ScribuntoContentHandler" + }, + "ResourceModuleFilePaths": { + "localBasePath": "modules", + "remoteExtPath": "Scribunto/modules" + }, + "ResourceModules": { + "ext.scribunto.errors": { + "scripts": "ext.scribunto.errors.js", + "styles": "ext.scribunto.errors.css", + "dependencies": [ + "jquery.ui.dialog" + ], + "messages": [ + "scribunto-parser-dialog-title" + ] + }, + "ext.scribunto.logs": { + "styles": "ext.scribunto.logs.css", + "position": "top" + }, + "ext.scribunto.edit": { + "scripts": "ext.scribunto.edit.js", + "styles": "ext.scribunto.edit.css", + "dependencies": [ + "mediawiki.api", + "jquery.spinner" + ], + "messages": [ + "scribunto-console-title", + "scribunto-console-intro", + "scribunto-console-clear", + "scribunto-console-cleared", + "scribunto-console-cleared-session-lost" + ] + } + }, + "APIModules": { + "scribunto-console": "ApiScribuntoConsole" + }, + "config": { + "ScribuntoDefaultEngine": "luastandalone", + "ScribuntoEngineConf": { + "luasandbox": { + "class": "Scribunto_LuaSandboxEngine", + "memoryLimit": 52428800, + "cpuLimit": 7, + "profilerPeriod": 0.02, + "allowEnvFuncs": false + }, + "luastandalone": { + "class": "Scribunto_LuaStandaloneEngine", + "errorFile": null, + "luaPath": null, + "memoryLimit": 52428800, + "cpuLimit": 7, + "allowEnvFuncs": false + } + }, + "ScribuntoUseGeSHi": false, + "ScribuntoUseCodeEditor": false, + "ScribuntoGatherFunctionStats": false, + "ScribuntoSlowFunctionThreshold": 0.90, + "NamespacesWithSubpages": { + "NS_MODULE": true, + "NS_MODULE_TALK": true + }, + "TrackingCategories": [ + "scribunto-common-error-category", + "scribunto-module-with-errors-category" + ] + } +} \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/265184 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id00a2a00bddf72f5c8716f21226695456b3a32c6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Scribunto Gerrit-Branch: master Gerrit-Owner: MtDu <justin.d...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits