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

Change subject: Implement ChangeTagsListActive hook
......................................................................


Implement ChangeTagsListActive hook

This allows users to visit Special:Tags or use the API to see
which change tags are still in active use.

The ChangeTagsListActive hook was introduced to core in
I77f476c8d0f32c80f720aa2c5e66869c81faa282

Change-Id: I456da1d151b576a4b4b62569a7804e3a3dd5e611
---
M AbuseFilter.hooks.php
M AbuseFilter.php
2 files changed, 27 insertions(+), 5 deletions(-)

Approvals:
  Anomie: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/AbuseFilter.hooks.php b/AbuseFilter.hooks.php
index 0e56125..cbceacb 100644
--- a/AbuseFilter.hooks.php
+++ b/AbuseFilter.hooks.php
@@ -442,25 +442,30 @@
        }
 
        /**
-        * @param $emptyTags array
+        * @param array $tags
+        * @param bool $enabled
         * @return bool
         */
-       public static function onListDefinedTags( &$emptyTags ) {
+       private static function fetchAllTags( array &$tags, $enabled ) {
                # This is a pretty awful hack.
                $dbr = wfGetDB( DB_SLAVE );
 
+               $where = array( 'afa_consequence' => 'tag' );
+               if ( $enabled ) {
+                       $where['af_enabled'] = true;
+               }
                $res = $dbr->select(
                        array( 'abuse_filter_action', 'abuse_filter' ),
                        'afa_parameters',
-                       array( 'afa_consequence' => 'tag', 'af_enabled' => true 
),
+                       $where,
                        __METHOD__,
                        array(),
                        array( 'abuse_filter' => array( 'INNER JOIN', 
'afa_filter=af_id' ) )
                );
 
                foreach ( $res as $row ) {
-                       $emptyTags = array_filter(
-                               array_merge( explode( "\n", 
$row->afa_parameters ), $emptyTags )
+                       $tags = array_filter(
+                               array_merge( explode( "\n", 
$row->afa_parameters ), $tags )
                        );
                }
 
@@ -468,6 +473,22 @@
        }
 
        /**
+        * @param array $tags
+        * @return bool
+        */
+       public static function onListDefinedTags( array &$tags ) {
+               return self::fetchAllTags( $tags, false );
+       }
+
+       /**
+        * @param array $tags
+        * @return bool
+        */
+       public static function onChangeTagsListActive( array &$tags ) {
+               return self::fetchAllTags( $tags, true );
+       }
+
+       /**
         * @param $updater DatabaseUpdater
         * @throws MWException
         * @return bool
diff --git a/AbuseFilter.php b/AbuseFilter.php
index 3b7de9b..46f7fb1 100644
--- a/AbuseFilter.php
+++ b/AbuseFilter.php
@@ -95,6 +95,7 @@
 $wgHooks['ArticleDelete'][] = 'AbuseFilterHooks::onArticleDelete';
 $wgHooks['RecentChange_save'][] = 'AbuseFilterHooks::onRecentChangeSave';
 $wgHooks['ListDefinedTags'][] = 'AbuseFilterHooks::onListDefinedTags';
+$wgHooks['ChangeTagsListActive'][] = 
'AbuseFilterHooks::onChangeTagsListActive';
 $wgHooks['LoadExtensionSchemaUpdates'][] = 
'AbuseFilterHooks::onLoadExtensionSchemaUpdates';
 $wgHooks['ContributionsToolLinks'][] = 
'AbuseFilterHooks::onContributionsToolLinks';
 $wgHooks['UploadVerifyFile'][] = 'AbuseFilterHooks::onUploadVerifyFile';

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I456da1d151b576a4b4b62569a7804e3a3dd5e611
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/AbuseFilter
Gerrit-Branch: master
Gerrit-Owner: TTO <at.li...@live.com.au>
Gerrit-Reviewer: Anomie <bjor...@wikimedia.org>
Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com>
Gerrit-Reviewer: Se4598 <se4...@gmx.de>
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