jenkins-bot has submitted this change and it was merged.
Change subject: Convert Insider extension to use new registration
......................................................................
Convert Insider extension to use new registration
Bug: T87932
Change-Id: I8106f309ea0de00890244af93ee9f7ef98317655
---
M Insider.class.php
D Insider.i18n.php
M Insider.php
A extension.json
4 files changed, 73 insertions(+), 90 deletions(-)
Approvals:
Florianschmidtwelzow: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Insider.class.php b/Insider.class.php
index c4fea80..3886668 100644
--- a/Insider.class.php
+++ b/Insider.class.php
@@ -1,22 +1,21 @@
<?php
class Insider {
- public $mInsiderSet = array();
+ public static $mInsiderSet = array();
/**
* @param Parser $parser
* @return bool
*/
- public static function parserHooks( Parser &$parser ) {
- global $wgInsider;
- $parser->setFunctionHook( 'insider', array( &$wgInsider,
'onFuncInsider' ) );
+ public static function onParserFirstCallInit( Parser &$parser ) {
+ $parser->setFunctionHook( 'insider', array( 'Insider',
'onFuncInsider' ) );
return true;
}
/**
* @return CustomData
*/
- public function getCustomData() {
+ public static function getCustomData() {
global $wgCustomData;
if ( !$wgCustomData instanceof CustomData ) {
@@ -30,17 +29,17 @@
* @param Parser $parser
* @return bool
*/
- public function onParserClearState( Parser &$parser ) {
- $this->mInsiderSet = array();
+ public static function onParserClearState( Parser &$parser ) {
+ self::$mInsiderSet = array();
return true;
}
- public function onFuncInsider() {
+ public static function onFuncInsider() {
$args = func_get_args();
array_shift( $args );
foreach ( $args as $insider ) {
- $this->mInsiderSet[] = $insider;
+ self::$mInsiderSet[] = $insider;
}
return '';
@@ -53,9 +52,9 @@
* @param string $text
* @return bool
*/
- public function onParserBeforeTidy( Parser &$parser, &$text ) {
- if ( $this->mInsiderSet ) {
- $this->getCustomData()->setParserData(
$parser->mOutput, 'Insider', $this->mInsiderSet );
+ public static function onParserBeforeTidy( Parser &$parser, &$text ) {
+ if ( self::$mInsiderSet ) {
+ self::getCustomData()->setParserData( $parser->mOutput,
'Insider', self::$mInsiderSet );
}
return true;
@@ -68,10 +67,10 @@
* @param QuickTemplate $QuickTmpl
* @return bool
*/
- public function onSkinTemplateOutputPageBeforeExec( SkinTemplate
&$skinTpl, &$QuickTmpl ) {
+ public static function onSkinTemplateOutputPageBeforeExec( SkinTemplate
&$skinTpl, &$QuickTmpl ) {
global $wgOut;
- $customData = $this->getCustomData();
+ $customData = self::getCustomData();
// Fill the Insider array.
$insiders = $customData->getPageData( $wgOut, 'Insider' );
@@ -84,7 +83,7 @@
* @param array $insiders
* @return array
*/
- protected function getInsiderUrls( array $insiders ) {
+ protected static function getInsiderUrls( array $insiders ) {
$insiderUrls = array();
foreach ( $insiders as $insider ) {
@@ -111,15 +110,15 @@
* @param array $bar
* @return bool
*/
- public function onSkinBuildSidebar( $skin, &$bar ) {
+ public static function onSkinBuildSidebar( $skin, &$bar ) {
$out = $skin->getOutput();
- $insiders = $this->getCustomData()->getParserData( $out,
'Insider' );
+ $insiders = self::getCustomData()->getParserData( $out,
'Insider' );
if ( count( $insiders ) == 0 ) {
return true;
}
- $insiderUrls = $this->getInsiderUrls( $insiders );
+ $insiderUrls = self::getInsiderUrls( $insiders );
// build insider <li>'s
$insiders = array();
@@ -158,14 +157,14 @@
* @param SkinTemplate|VectorTemplate $skinTpl
* @return bool
*/
- public function onSkinTemplateToolboxEnd( &$skinTpl ) {
- $insiders = $this->getCustomData()->getSkinData( $skinTpl,
'Insider' );
+ public static function onSkinTemplateToolboxEnd( &$skinTpl ) {
+ $insiders = self::getCustomData()->getSkinData( $skinTpl,
'Insider' );
if ( count( $insiders ) == 0 ) {
return true;
}
- $insiderUrls = $this->getInsiderUrls( $insiders );
+ $insiderUrls = self::getInsiderUrls( $insiders );
// build insider <li>'s
$insiders = array();
diff --git a/Insider.i18n.php b/Insider.i18n.php
deleted file mode 100644
index 946dc8f..0000000
--- a/Insider.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( 'wfJsonI18nShim109ec1bb53a77131' ) ) {
- function wfJsonI18nShim109ec1bb53a77131( $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'][] =
'wfJsonI18nShim109ec1bb53a77131';
-}
diff --git a/Insider.php b/Insider.php
index 56c996c..f68ef25 100644
--- a/Insider.php
+++ b/Insider.php
@@ -1,36 +1,14 @@
<?php
-
-if ( !defined( 'MEDIAWIKI' ) ) {
- die( 'This file is a MediaWiki extension, it is not a valid entry
point' );
+if ( function_exists( 'wfLoadExtension' ) ) {
+ wfLoadExtension( 'Insider' );
+ // Keep i18n globals so mergeMessageFileList.php doesn't break
+ $wgMessagesDirs['Insider'] = __DIR__ . '/i18n';
+ $wgExtensionMessagesFiles['InsiderMagic'] = __DIR__ .
'/Insider.i18n.magic.php';
+ /*wfWarn(
+ 'Deprecated PHP entry point used for Insider extension. Please
use wfLoadExtension instead, ' .
+ 'see https://www.mediawiki.org/wiki/Extension_registration for
more details.'
+ );*/
+ return;
+} else {
+ die( 'This version of the Insider extension requires MediaWiki 1.25+' );
}
-
-// autoloader
-$wgAutoloadClasses['Insider'] = __DIR__ . '/Insider.class.php';
-
-// extension & magic words i18n
-$wgMessagesDirs['Insider'] = __DIR__ . '/i18n';
-$wgExtensionMessagesFiles['Insider'] = __DIR__ . '/Insider.i18n.php';
-$wgExtensionMessagesFiles['InsiderMagic'] = __DIR__ .
'/Insider.i18n.magic.php';
-
-// hooks
-$wgInsider = new Insider;
-$wgHooks['ParserFirstCallInit'][] = 'Insider::parserHooks';
-$wgHooks['SkinTemplateOutputPageBeforeExec'][] = array( &$wgInsider,
'onSkinTemplateOutputPageBeforeExec' );
-$wgHooks['ParserClearState'][] = array( &$wgInsider, 'onParserClearState' );
-$wgHooks['ParserBeforeTidy'][] = array( &$wgInsider, 'onParserBeforeTidy' );
-
-// 2 same hooks, with different position though - enable what you want
-// the first one is a "clean" solution, but has its content inserted _before_
the toolbox
-//$wgHooks['SkinBuildSidebar'][] = array( &$wgInsider, 'onSkinBuildSidebar' );
-// the second one is nasty: echo'ing raw html _after_ the regular toolbox
-$wgHooks['SkinTemplateToolboxEnd'][] = array( &$wgInsider,
'onSkinTemplateToolboxEnd' );
-
-// credits
-$wgExtensionCredits['parserhook']['Insider'] = array(
- 'path' => __FILE__,
- 'name' => 'Insider',
- 'url' => '//www.mediawiki.org/wiki/Extension:Insider',
- 'descriptionmsg' => 'insider-desc',
- 'author' => array( 'Roland Unger', 'Hans Musil', 'Matthias Mullie' ),
- 'version' => '1.2.0'
-);
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..a2231d6
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,41 @@
+{
+ "name": "Insider",
+ "url": "https://www.mediawiki.org/wiki/Extension:Insider",
+ "descriptionmsg": "insider-desc",
+ "author": [
+ "Roland Unger",
+ "Hans Musil",
+ "Matthias Mullie"
+ ],
+ "version": "1.2.1",
+ "type": "parserhook",
+ "AutoloadClasses": {
+ "Insider": "Insider.class.php"
+ },
+ "MessageDirs": {
+ "Insider": [
+ "i18n"
+ ]
+ },
+ "ExtensionMessagesFiles": {
+ "InsiderMagic": "Insider.i18n.magic.php"
+ },
+ "Hooks": {
+ "ParserFirstCallInit": [
+ "Insider::onParserFirstCallInit"
+ ],
+ "SkinTemplateOutputPageBeforeExec": [
+ "Insider::onSkinTemplateOutputPageBeforeExec"
+ ],
+ "ParserClearState": [
+ "Insider::onParserClearState"
+ ],
+ "ParserBeforeTidy": [
+ "Insider::onParserBeforeTidy"
+ ],
+ "SkinTemplateToolboxEnd": [
+ "Insider::onSkinTemplateToolboxEnd"
+ ]
+ },
+ "manifest_version": 1
+}
--
To view, visit https://gerrit.wikimedia.org/r/263311
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8106f309ea0de00890244af93ee9f7ef98317655
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Insider
Gerrit-Branch: master
Gerrit-Owner: MtDu <[email protected]>
Gerrit-Reviewer: Aklapper <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: MtDu <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits