jenkins-bot has submitted this change and it was merged.

Change subject: Add extensions.json, empty PHP entry point, remove i18n shim
......................................................................


Add extensions.json, empty PHP entry point, remove i18n shim

Bug: T88059
Change-Id: I730a2012609f7dfac3d49012ae14038e6bcac3ae
---
D SpamBlacklist.i18n.php
M SpamBlacklist.php
M SpamBlacklistHooks.php
A extension.json
4 files changed, 104 insertions(+), 110 deletions(-)

Approvals:
  Paladox: Looks good to me, but someone else must approve
  Alex Monk: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/SpamBlacklist.i18n.php b/SpamBlacklist.i18n.php
deleted file mode 100644
index 7f463b0..0000000
--- a/SpamBlacklist.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( 'wfJsonI18nShime2760ddac42b5b1c' ) ) {
-       function wfJsonI18nShime2760ddac42b5b1c( $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'][] = 
'wfJsonI18nShime2760ddac42b5b1c';
-}
diff --git a/SpamBlacklist.php b/SpamBlacklist.php
index b627e00..a1e4960 100644
--- a/SpamBlacklist.php
+++ b/SpamBlacklist.php
@@ -1,77 +1,13 @@
 <?php
-
-# Loader for spam blacklist feature
-# Include this from LocalSettings.php
-
-if ( !defined( 'MEDIAWIKI' ) ) {
-       exit;
+if ( function_exists( 'wfLoadExtension' ) ) {
+       wfLoadExtension( 'SpamBlacklist' );
+       // Keep i18n globals so mergeMessageFileList.php doesn't break
+       $wgMessagesDirs['SpamBlackList'] = __DIR__ . '/i18n';
+       /* wfWarn(
+               'Deprecated PHP entry point used for SpamBlacklist extension. 
Please use wfLoadExtension instead, ' .
+               'see https://www.mediawiki.org/wiki/Extension_registration for 
more details.'
+       ); */
+       return;
+} else {
+       die( 'This version of the SpamBlacklist extension requires MediaWiki 
1.25+' );
 }
-
-$wgExtensionCredits['antispam'][] = array(
-       'path'           => __FILE__,
-       'name'           => 'SpamBlacklist',
-       'author'         => array( 'Tim Starling', 'John Du Hart', 'Daniel 
Kinzler' ),
-       'url'            => 
'https://www.mediawiki.org/wiki/Extension:SpamBlacklist',
-       'descriptionmsg' => 'spam-blacklist-desc',
-);
-
-$dir = __DIR__ . '/';
-$wgMessagesDirs['SpamBlackList'] = __DIR__ . '/i18n';
-$wgExtensionMessagesFiles['SpamBlackList'] = $dir . 'SpamBlacklist.i18n.php';
-
-// Register the API method
-$wgAutoloadClasses['ApiSpamBlacklist'] = "$dir/api/ApiSpamBlacklist.php";
-$wgAPIModules['spamblacklist'] = 'ApiSpamBlacklist';
-
-/**
- * Array of settings for blacklist classes
- */
-$wgBlacklistSettings = array(
-       'spam' => array(
-               'files' => array( 
"https://meta.wikimedia.org/w/index.php?title=Spam_blacklist&action=raw&sb_ver=1";
 )
-       )
-);
-
-/**
- * Log blacklist hits to Special:Log
- */
-$wgLogSpamBlacklistHits = false;
-
-/**
- * @deprecated
- */
-$wgSpamBlacklistFiles =& $wgBlacklistSettings['spam']['files'];
-
-/**
- * @deprecated
- */
-$wgSpamBlacklistSettings =& $wgBlacklistSettings['spam'];
-
-if ( !defined( 'MW_SUPPORTS_CONTENTHANDLER' ) ) {
-       die( "This version of SpamBlacklist requires a version of MediaWiki 
that supports the ContentHandler facility (supported since MW 1.21)." );
-}
-
-// filter pages on save
-$wgHooks['EditFilterMergedContent'][] = 
'SpamBlacklistHooks::filterMergedContent';
-$wgHooks['APIEditBeforeSave'][] = 
'SpamBlacklistHooks::filterAPIEditBeforeSave';
-
-// editing filter rules
-$wgHooks['EditFilter'][] = 'SpamBlacklistHooks::validate';
-$wgHooks['PageContentSaveComplete'][] = 'SpamBlacklistHooks::pageSaveContent';
-
-// email filters
-$wgHooks['UserCanSendEmail'][] = 'SpamBlacklistHooks::userCanSendEmail';
-$wgHooks['AbortNewAccount'][] = 'SpamBlacklistHooks::abortNewAccount';
-
-$wgAutoloadClasses['BaseBlacklist'] = $dir . 'BaseBlacklist.php';
-$wgAutoloadClasses['EmailBlacklist'] = $dir . 'EmailBlacklist.php';
-$wgAutoloadClasses['SpamBlacklistHooks'] = $dir . 'SpamBlacklistHooks.php';
-$wgAutoloadClasses['SpamBlacklist'] = $dir . 'SpamBlacklist_body.php';
-$wgAutoloadClasses['SpamRegexBatch'] = $dir . 'SpamRegexBatch.php';
-
-$wgLogTypes[] = 'spamblacklist';
-$wgLogActionsHandlers['spamblacklist/*'] = 'LogFormatter';
-$wgLogRestrictions['spamblacklist'] = 'spamblacklistlog';
-$wgGroupPermissions['sysop']['spamblacklistlog'] = true;
-
-$wgAvailableRights[] = 'spamblacklistlog';
diff --git a/SpamBlacklistHooks.php b/SpamBlacklistHooks.php
index 27a2dab..877882d 100755
--- a/SpamBlacklistHooks.php
+++ b/SpamBlacklistHooks.php
@@ -4,6 +4,30 @@
  * Hooks for the spam blacklist extension
  */
 class SpamBlacklistHooks {
+
+    /**
+     * T99257: Extension registration does not properly support 2d arrays so 
set it as a global for now
+     */
+       public static function registerExtension() {
+               global $wgSpamBlacklistFiles, $wgBlacklistSettings, 
$wgSpamBlacklistSettings;
+
+               $wgBlacklistSettings = array(
+                       'spam' => array(
+                               'files' => array( 
"https://meta.wikimedia.org/w/index.php?title=Spam_blacklist&action=raw&sb_ver=1";
 )
+                       )
+               );
+
+               /**
+                * @deprecated
+                */
+               $wgSpamBlacklistFiles =& $wgBlacklistSettings['spam']['files'];
+
+               /**
+                * @deprecated
+                */
+               $wgSpamBlacklistSettings =& $wgBlacklistSettings['spam'];
+       }
+
        /**
         * Hook function for EditFilterMergedContent
         *
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..7aec2bc
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,69 @@
+{
+       "name": "SpamBlacklist",
+       "author": [
+               "Tim Starling",
+               "John Du Hart",
+               "Daniel Kinzler"
+       ],
+       "url": "https://www.mediawiki.org/wiki/Extension:SpamBlacklist";,
+       "descriptionmsg": "spam-blacklist-desc",
+       "type": "antispam",
+       "callback": "SpamBlacklistHooks::registerExtension",
+       "GroupPermissions": {
+               "sysop": {
+                       "spamblacklistlog": true
+               }
+       },
+       "AvailableRights": [
+               "spamblacklistlog"
+       ],
+       "LogTypes": [
+               "spamblacklist"
+       ],
+       "LogRestrictions": {
+               "spamblacklist": "spamblacklistlog"
+       },
+       "LogActionsHandlers": {
+               "spamblacklist/*": "LogFormatter"
+       },
+       "APIModules": {
+               "spamblacklist": "ApiSpamBlacklist"
+       },
+       "MessagesDirs": {
+               "SpamBlackList": [
+                       "i18n"
+               ]
+       },
+       "AutoloadClasses": {
+               "ApiSpamBlacklist": "api/ApiSpamBlacklist.php",
+               "BaseBlacklist": "BaseBlacklist.php",
+               "EmailBlacklist": "EmailBlacklist.php",
+               "SpamBlacklistHooks": "SpamBlacklistHooks.php",
+               "SpamBlacklist": "SpamBlacklist_body.php",
+               "SpamRegexBatch": "SpamRegexBatch.php"
+       },
+       "Hooks": {
+               "EditFilterMergedContent": [
+                       "SpamBlacklistHooks::filterMergedContent"
+               ],
+               "APIEditBeforeSave": [
+                       "SpamBlacklistHooks::filterAPIEditBeforeSave"
+               ],
+               "EditFilter": [
+                       "SpamBlacklistHooks::validate"
+               ],
+               "PageContentSaveComplete": [
+                       "SpamBlacklistHooks::pageSaveContent"
+               ],
+               "UserCanSendEmail": [
+                       "SpamBlacklistHooks::userCanSendEmail"
+               ],
+               "AbortNewAccount": [
+                       "SpamBlacklistHooks::abortNewAccount"
+               ]
+       },
+       "config": {
+               "@doc": "BlacklistSettings are set in SpamBlacklistHooks.php",
+               "LogSpamBlacklistHits": false
+       }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/209804
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I730a2012609f7dfac3d49012ae14038e6bcac3ae
Gerrit-PatchSet: 11
Gerrit-Project: mediawiki/extensions/SpamBlacklist
Gerrit-Branch: master
Gerrit-Owner: Paladox <thomasmulhall...@yahoo.com>
Gerrit-Reviewer: Alex Monk <kren...@gmail.com>
Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Paladox <thomasmulhall...@yahoo.com>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: Yurik <yu...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to