Cenarium has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/313189

Change subject: Allow external logging of definitions and activations
......................................................................

Allow external logging of definitions and activations

Change-Id: I234b43aeb0c97a20002d2a4ecc6738f53c3f87b6
---
M includes/DefaultSettings.php
M includes/changetags/ChangeTagsManager.php
M languages/i18n/en.json
3 files changed, 47 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/89/313189/1

diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 1402ab0..222b7f3 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -7544,6 +7544,8 @@
        'managetags/create' => 'LogFormatter',
        'managetags/deactivate' => 'LogFormatter',
        'managetags/delete' => 'LogFormatter',
+       'managetags/define' => 'LogFormatter',
+       'managetags/undefine' => 'LogFormatter',
        'merge/merge' => 'MergeLogFormatter',
        'move/move' => 'MoveLogFormatter',
        'move/move_redir' => 'MoveLogFormatter',
diff --git a/includes/changetags/ChangeTagsManager.php 
b/includes/changetags/ChangeTagsManager.php
index 70dabf3..fe4b13b 100644
--- a/includes/changetags/ChangeTagsManager.php
+++ b/includes/changetags/ChangeTagsManager.php
@@ -42,6 +42,11 @@
        protected $ignoreWarnings;
 
        /**
+        * @var Title
+        */
+       protected $target = null;
+
+       /**
         * @param ChangeTagsContext $context
         * @param User $performer
         * @param bool $ignoreWarnings
@@ -52,6 +57,16 @@
                $this->context = $context;
                $this->performer = $performer;
                $this->ignoreWarnings = $ignoreWarnings;
+       }
+
+       /**
+        * Specify which target page to set for logging.
+        *
+        * @param Title $target
+        * @since 1.28
+        */
+       public function setTarget( Title $target ) {
+               $this->target = $target;
        }
 
        /**
@@ -93,6 +108,7 @@
                ChangeTagsContext::purgeStoredTagsCache();
 
                // log it
+               $this->setTarget( Title::newFromText( 'Special:Tags' ) );
                $logId = $this->logTagManagementAction( 'activate', $tag, 
$reason );
                return Status::newGood( $logId );
        }
@@ -133,6 +149,7 @@
                ChangeTagsContext::purgeStoredTagsCache();
 
                // log it
+               $this->setTarget( Title::newFromText( 'Special:Tags' ) );
                $logId = $this->logTagManagementAction( 'deactivate', $tag, 
$reason );
                return Status::newGood( $logId );
        }
@@ -175,6 +192,7 @@
                ChangeTagsContext::purgeStoredTagsCache();
 
                // log it
+               $this->setTarget( Title::newFromText( 'Special:Tags' ) );
                $logId = $this->logTagManagementAction( 'create', $tag, $reason 
);
                return Status::newGood( $logId );
        }
@@ -217,9 +235,26 @@
                }
 
                // log it
+               $this->setTarget( Title::newFromText( 'Special:Tags' ) );
                $logId = $this->logTagManagementAction( 'delete', $tag, 
$reason, $hitcount );
                $deleteResult->value = $logId;
                return $deleteResult;
+       }
+
+       public function logExternalDefinition( $tag, $reason = '' ) {
+               $this->logTagManagementAction( 'define', $tag, $reason );
+       }
+
+       public function logExternalActivation( $tag, $reason = '' ) {
+               $this->logTagManagementAction( 'activate', $tag, $reason );
+       }
+
+       public function logExternalDeactivation( $tag, $reason = '' ) {
+               $this->logTagManagementAction( 'deactivate', $tag, $reason );
+       }
+
+       public function logExternalUndefinition( $tag, $reason = '' ) {
+               $this->logTagManagementAction( 'undefine', $tag, $reason );
        }
 
        /**
@@ -234,14 +269,15 @@
         * @since 1.25
         */
        protected function logTagManagementAction( $action, $tag, $reason, 
$tagCount = null ) {
+               if ( $this->target === null ) {
+                       throw new MWException( 'No target was specified!' );
+               }
 
                $dbw = wfGetDB( DB_MASTER );
 
                $logEntry = new ManualLogEntry( 'managetags', $action );
                $logEntry->setPerformer( $this->performer );
-               // target page is not relevant, but it has to be set, so we 
just put in
-               // the title of Special:Tags
-               $logEntry->setTarget( Title::newFromText( 'Special:Tags' ) );
+               $logEntry->setTarget( $this->target );
                $logEntry->setComment( $reason );
 
                $params = [ '4::tag' => $tag ];
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index 8e3a535..e93e39e 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -3865,10 +3865,12 @@
        "logentry-upload-revert": "$1 {{GENDER:$2|uploaded}} $3",
        "log-name-managetags": "Tag management log",
        "log-description-managetags": "This page lists management tasks related 
to [[Special:Tags|tags]]. The log contains only actions carried out manually by 
an administrator; tags may be created or deleted by the wiki software without 
an entry being recorded in this log.",
-       "logentry-managetags-create": "$1 {{GENDER:$2|created}} the tag \"$4\"",
-       "logentry-managetags-delete": "$1 {{GENDER:$2|deleted}} the tag \"$4\" 
(removed from $5 {{PLURAL:$5|revision or log entry|revisions and/or log 
entries}})",
-       "logentry-managetags-activate": "$1 {{GENDER:$2|activated}} the tag 
\"$4\" for use by users and bots",
-       "logentry-managetags-deactivate": "$1 {{GENDER:$2|deactivated}} the tag 
\"$4\" for use by users and bots",
+       "logentry-managetags-create": "$1 {{GENDER:$2|created}} the tag \"$4\" 
at $3",
+       "logentry-managetags-delete": "$1 {{GENDER:$2|deleted}} the tag \"$4\" 
at $3 (removed from $5 {{PLURAL:$5|revision or log entry|revisions and/or log 
entries}})",
+       "logentry-managetags-activate": "$1 {{GENDER:$2|activated}} the tag 
\"$4\" at $3",
+       "logentry-managetags-deactivate": "$1 {{GENDER:$2|deactivated}} the tag 
\"$4\" at $3",
+       "logentry-managetags-define": "$1 {{GENDER:$2|defined}} the tag \"$4\" 
at $3",
+       "logentry-managetags-undefine": "$1 {{GENDER:$2|undefined}} the tag 
\"$4\" at $3",
        "log-name-tag": "Tag log",
        "log-description-tag": "This page shows when users have added or 
removed [[Special:Tags|tags]] from individual revisions or log entries. The log 
does not list tagging actions when they occur as part of an edit, deletion, or 
similar action.",
        "logentry-tag-update-add-revision": "$1 {{GENDER:$2|added}} the 
{{PLURAL:$7|tag|tags}} $6 to revision $4 of page $3",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I234b43aeb0c97a20002d2a4ecc6738f53c3f87b6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Cenarium <cenarium.sy...@gmail.com>

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

Reply via email to