jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/367888 )
Change subject: Do some maintenance ...................................................................... Do some maintenance * Remove I18n php shim * Remove check for hooks in MW 1.20 and earlier * Remove dead code for versions of MW 1.22 and earlier * Extend author's array * Bump version Note: This is breaking for MW 1.22.x and earlier. Bug:T168353 Change-Id: I7245331368edf261b15d98bd070a4a44e9c9d879 --- D Variables.i18n.php M Variables.php 2 files changed, 21 insertions(+), 90 deletions(-) Approvals: Umherirrender: Looks good to me, approved jenkins-bot: Verified diff --git a/Variables.i18n.php b/Variables.i18n.php deleted file mode 100644 index a6d0875..0000000 --- a/Variables.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( 'wfJsonI18nShima592af7679c7ce4d' ) ) { - function wfJsonI18nShima592af7679c7ce4d( $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'][] = 'wfJsonI18nShima592af7679c7ce4d'; -} diff --git a/Variables.php b/Variables.php index 2d484fb..84d6c90 100644 --- a/Variables.php +++ b/Variables.php @@ -6,7 +6,7 @@ * * Documentation: https://www.mediawiki.org/wiki/Extension:Variables * Support: https://www.mediawiki.org/wiki/Extension_talk:Variables - * Source code: https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Variables.git + * Source code: https://phabricator.wikimedia.org/diffusion/EVAR/ * * @license: ISC License * @author: Rob Adams @@ -18,42 +18,39 @@ * @ingroup Variables */ -if ( ! defined( 'MEDIAWIKI' ) ) { die(); } +// Ensure that the script cannot be executed outside of MediaWiki. +if ( !defined( 'MEDIAWIKI' ) ) { + die( 'This is an extension to MediaWiki and cannot be run standalone.' ); +} +// Display extension properties on MediaWiki. $wgExtensionCredits['parserhook'][] = array( - 'path' => __FILE__, - 'name' => 'Variables', + 'path' => __FILE__, + 'name' => 'Variables', 'descriptionmsg' => 'variables-desc', - 'version' => ExtVariables::VERSION, - 'author' => array( + 'version' => ExtVariables::VERSION, + 'author' => array( 'Rob Adams', 'Tom Hempel', 'Xiloynaha', - '[https://www.mediawiki.org/wiki/User:Danwe Daniel Werner]' + '[https://www.mediawiki.org/wiki/User:Danwe Daniel Werner]', + '...' ), - 'url' => 'https://www.mediawiki.org/wiki/Extension:Variables', - 'license-name' => 'ISC' + 'url' => 'https://www.mediawiki.org/wiki/Extension:Variables', + 'license-name' => 'ISC' ); // language files: $wgMessagesDirs['Variables'] = __DIR__ . '/i18n'; -$wgExtensionMessagesFiles['Variables' ] = ExtVariables::getDir() . '/Variables.i18n.php'; $wgExtensionMessagesFiles['VariablesMagic'] = ExtVariables::getDir() . '/Variables.i18n.magic.php'; // hooks registration: -$wgHooks['ParserFirstCallInit' ][] = 'ExtVariables::init'; -$wgHooks['ParserClearState' ][] = 'ExtVariables::onParserClearState'; +$wgHooks['ParserFirstCallInit'][] = 'ExtVariables::init'; +$wgHooks['ParserClearState'][] = 'ExtVariables::onParserClearState'; +$wgHooks['InternalParseBeforeSanitize'][] = 'ExtVariables::onInternalParseBeforeSanitize'; // parser tests registration: $wgParserTestFiles[] = ExtVariables::getDir() . '/tests/mwparsertests/Variables.txt'; - -if( version_compare( $wgVersion, '1.20', '<' ) ) { - // fallback for InternalParseBeforeSanitize hook - $wgHooks['InternalParseBeforeLinks'][] = 'ExtVariables::onInternalParseBeforeLinks'; -} else { - // this hook is available from MW 1.20 on - $wgHooks['InternalParseBeforeSanitize'][] = 'ExtVariables::onInternalParseBeforeSanitize'; -} // Include the settings file: require_once ExtVariables::getDir() . '/Variables.settings.php'; @@ -73,7 +70,7 @@ * * @var string */ - const VERSION = '2.1.0'; + const VERSION = '2.2.0'; /** * Internal store for variable values @@ -245,31 +242,6 @@ } /** - * Used to call and sanitize output by onInternalParseBeforeSanitize() in case of MediaWiki < 1.20 is used which - * doesn't support the 'InternalParseBeforeSanitize' hook. - * @see http://www.mediawiki.org/wiki/Manual:Hooks/InternalParseBeforeLinks - * - * @since 2.0 - */ - static function onInternalParseBeforeLinks( Parser &$parser, &$text ) { - // do same stuff we would do in MW 1.20+... - self::onInternalParseBeforeSanitize( $parser, $text ); - // ...but take care of additional necessary sanitizing then: - - /* - * Sanitize the whole thing, otherwise HTML and JS code injection would be possible. - * Basically the same is happening in Parser::internalParse() right before 'InternalParseBeforeLinks' hook is called. - */ - $text = Sanitizer::removeHTMLtags( - $text, - array( &$parser, 'attributeStripCallback' ), - false, - array_keys( $parser->mTransparentTagHooks ) - ); - return true; - } - - /** * This will clean up the variables store after parsing has finished. It will prevent strange things to happen * for example during import of several pages or job queue is running for multiple pages. In these cases variables * would become some kind of superglobals, being passed from one page to the other. @@ -290,16 +262,10 @@ ################## /** - * Takes care of setting a strip state pair in MW 1.18 as well as in previous versions + * Takes care of setting a strip state pair */ protected function stripStatePair( $marker, $value ) { - global $wgVersion; - if( version_compare( $wgVersion, '1.17.99', '>' ) ) { - // MW 1.18alpha+ - $this->mFinalizedVarsStripState->addGeneral( $marker, $value ); - } else { - $this->mFinalizedVarsStripState->general->setPair( $marker, $value ); - } + $this->mFinalizedVarsStripState->addGeneral( $marker, $value ); } @@ -394,7 +360,7 @@ } $id = count( $this->mFinalizedVars ); /* - * strip-item which will be unstripped in self::onInternalParseBeforeLinks() + * strip-item which will be unstripped in self::onInternalParseBeforeSanitize() * In case the requested final variable has a value in the end, this strip-item * value will be replaced with that value before unstripping. */ -- To view, visit https://gerrit.wikimedia.org/r/367888 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7245331368edf261b15d98bd070a4a44e9c9d879 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/Variables Gerrit-Branch: master Gerrit-Owner: Kghbln <[email protected]> Gerrit-Reviewer: Kghbln <[email protected]> Gerrit-Reviewer: Reedy <[email protected]> Gerrit-Reviewer: Siebrand <[email protected]> Gerrit-Reviewer: Umherirrender <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
