jenkins-bot has submitted this change and it was merged. Change subject: Convert TrustedXFF to use extension registration ......................................................................
Convert TrustedXFF to use extension registration Bug: T88065 Change-Id: I387db114990c62d8eaeb709d8ee870ed79053f8f --- D TrustedXFF.i18n.php M TrustedXFF.php A extension.json 3 files changed, 43 insertions(+), 68 deletions(-) Approvals: Reedy: Looks good to me, approved jenkins-bot: Verified diff --git a/TrustedXFF.i18n.php b/TrustedXFF.i18n.php deleted file mode 100644 index eeb2776..0000000 --- a/TrustedXFF.i18n.php +++ /dev/null @@ -1,31 +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(); -$GLOBALS['wgHooks']['LocalisationCacheRecache'][] = function ( $cache, $code, &$cachedData ) { - $codeSequence = array_merge( array( $code ), $cachedData['fallbackSequence'] ); - foreach ( $codeSequence as $csCode ) { - $fileName = __DIR__ . "/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; -}; diff --git a/TrustedXFF.php b/TrustedXFF.php index d85de9d..9fc486f 100644 --- a/TrustedXFF.php +++ b/TrustedXFF.php @@ -1,38 +1,14 @@ <?php - -// Entry point protection -if ( !defined( 'MEDIAWIKI' ) ) { - die( 'This is an extension to MediaWiki and cannot be run standalone.' ); -} - -/** - * Trusted hosts file in CDB format. - * The file can be generated using generate.php - * - * You can download Wikimedia's trusted-xff.cdb from: - * - * https://noc.wikimedia.org/conf/trusted-xff.cdb - * - * For details, see https://meta.wikimedia.org/wiki/XFF_project - */ -$wgTrustedXffFile = $IP . '/cache/trusted-xff.cdb'; - -// Register extension -$wgExtensionCredits['other'][] = array( - 'path' => __FILE__, - 'name' => 'TrustedXFF', - 'descriptionmsg' => 'trustedxff-desc', - 'author' => 'Tim Starling', - 'url' => 'https://www.mediawiki.org/wiki/Extension:TrustedXFF', - 'license-name' => 'GPL-2.0+' -); - -// Load class -$wgAutoloadClasses['TrustedXFF'] = __DIR__ . '/TrustedXFF.body.php'; - -// I18n files -$wgMessagesDirs['TrustedXFF'] = __DIR__ . '/i18n'; -$wgExtensionMessagesFiles['TrustedXFF'] = __DIR__ . '/TrustedXFF.i18n.php'; - -// Load hook -$wgHooks['IsTrustedProxy'][] = 'TrustedXFF::onIsTrustedProxy'; +if ( function_exists( 'wfLoadExtension' ) ) { + wfLoadExtension( 'TrustedXFF' ); + // Keep i18n globals so mergeMessageFileList.php doesn't break + $wgMessagesDirs['TrustedXFF'] = __DIR__ . '/i18n'; + /*wfWarn( + 'Deprecated PHP entry point used for TrustedXFF extension. ' . + 'Please use wfLoadExtension instead, ' . + 'see https://www.mediawiki.org/wiki/Extension_registration for more details.' + );*/ + return; +} else { + die( 'This version of the TrustedXFF extension requires MediaWiki 1.25+' ); +} \ No newline at end of file diff --git a/extension.json b/extension.json new file mode 100644 index 0000000..c5a27f0 --- /dev/null +++ b/extension.json @@ -0,0 +1,30 @@ +{ + "name": "TrustedXFF", + "license-name": "GPL-2.0+", + "url": "https://www.mediawiki.org/wiki/Extension:TrustedXFF", + "descriptionmsg": "trustedxff-desc", + "author": [ + "Tim Starling" + ], + "type": "other", + "config": { + "TrustedXffFile": { + "value": "cache/trusted-xff.cdb", + "path": true + } + }, + "AutoloadClasses": { + "TrustedXFF": "TrustedXFF.body.php" + }, + "MessageDirs": { + "TrustedXFF": [ + "i18n" + ] + }, + "Hooks": { + "IsTrustedProxy": [ + "TrustedXFF::onIsTrustedProxy" + ] + }, + "manifest_version": 2 +} -- To view, visit https://gerrit.wikimedia.org/r/300550 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I387db114990c62d8eaeb709d8ee870ed79053f8f Gerrit-PatchSet: 6 Gerrit-Project: mediawiki/extensions/TrustedXFF Gerrit-Branch: master Gerrit-Owner: MtDu <justin.d...@gmail.com> Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Reedy <re...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits