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

Change subject: Allow for searching the global rename log by previous username
......................................................................


Allow for searching the global rename log by previous username

Requires If8bdbadd88 in core.

TODO: Write a script to back-populate log_search.

Bug: 70850
Change-Id: I13c39874ff5f8690002658a34b9bcdf523ed0776
---
M CentralAuth.php
M i18n/en.json
M i18n/qqq.json
M includes/CentralAuthHooks.php
M includes/GlobalRename/GlobalRenameUserLogger.php
5 files changed, 45 insertions(+), 2 deletions(-)

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



diff --git a/CentralAuth.php b/CentralAuth.php
index 0aec469..46525f1 100644
--- a/CentralAuth.php
+++ b/CentralAuth.php
@@ -357,6 +357,8 @@
 $wgHooks['APIGetParamDescription'][] = 
'CentralAuthHooks::onAPIGetParamDescription';
 $wgHooks['ApiCheckCanExecute'][] = 'CentralAuthHooks::onApiCheckCanExecute';
 $wgHooks['TestCanonicalRedirect'][] = 
'CentralAuthHooks::onTestCanonicalRedirect';
+$wgHooks['LogEventsListGetExtraInputs'][] = 
'CentralAuthHooks::onLogEventsListGetExtraInputs';
+$wgHooks['SpecialLogAddLogSearchRelations'][] = 
'CentralAuthHooks::onSpecialLogAddLogSearchRelations';
 $wgHooks['UnitTestsList'][] = 'CentralAuthHooks::onUnitTestsList';
 
 // For interaction with the Special:Renameuser extension
diff --git a/i18n/en.json b/i18n/en.json
index d800e4d..01ed1d8 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -525,5 +525,6 @@
        "apihelp-setglobalaccountstatus-param-reason": "Reason for changing the 
user's status.",
        "apihelp-setglobalaccountstatus-param-statecheck": "Optional MD5 of the 
expected current <username>:<hidden>:<locked>, to detect edit conflicts. Set 
<locked> to 1 for locked, 0 for unlocked.",
        "apihelp-setglobalaccountstatus-example-1": "Lock the global account 
for [[User:Example]] with reason \"Spam\"",
-       "apihelp-setglobalaccountstatus-example-2": "Unlock and suppress the 
global account for [[User:Example]] with reason \"I can\""
+       "apihelp-setglobalaccountstatus-example-2": "Unlock and suppress the 
global account for [[User:Example]] with reason \"I can\"",
+       "centralauth-log-gblrename-oldname": "Previous username"
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 1d2f72c..d21004e 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -536,5 +536,6 @@
        "apihelp-setglobalaccountstatus-param-reason": 
"{{doc-apihelp-param|setglobalaccountstatus|reason}}",
        "apihelp-setglobalaccountstatus-param-statecheck": 
"{{doc-apihelp-param|setglobalaccountstatus|statecheck}}",
        "apihelp-setglobalaccountstatus-example-1": 
"{{doc-apihelp-example|setglobalaccountstatus}}",
-       "apihelp-setglobalaccountstatus-example-2": 
"{{doc-apihelp-example|setglobalaccountstatus}}"
+       "apihelp-setglobalaccountstatus-example-2": 
"{{doc-apihelp-example|setglobalaccountstatus}}",
+       "centralauth-log-gblrename-oldname": "Label for field on Special:Log 
which allows filtering the global rename log by the previous username"
 }
diff --git a/includes/CentralAuthHooks.php b/includes/CentralAuthHooks.php
index c07e89b..1d3eb66 100644
--- a/includes/CentralAuthHooks.php
+++ b/includes/CentralAuthHooks.php
@@ -1939,4 +1939,38 @@
                }
                return true;
        }
+
+       /**
+        * @param $type
+        * @param WebRequest $request
+        * @param array $qc
+        * @return bool
+        */
+       public static function onSpecialLogAddLogSearchRelations( $type, 
WebRequest $request, array &$qc ) {
+               if ( $type === 'gblrename' ) {
+                       $oldname = User::getCanonicalName( $request->getVal( 
'oldname' ) );
+                       if ( $oldname !== false ) {
+                               $qc = array( 'ls_field' => 'oldname', 
'ls_value' => $oldname );
+                       }
+               }
+
+               return true;
+       }
+
+       public static function onLogEventsListGetExtraInputs( $type, 
LogEventsList $list, &$input ) {
+               if ( $type === 'gblrename' ) {
+                       $value = $list->getRequest()->getVal( 'oldname' );
+                       if ( $value !== null ) {
+                               $name = User::getCanonicalName( $value );
+                               $value = $name !== false ? $name : '';
+                       }
+                       $input = Xml::inputLabel(
+                               $list->msg( 'centralauth-log-gblrename-oldname' 
)->text(),
+                               'oldname',
+                               'mw-log-gblrename-oldname',
+                               20,
+                               $value
+                       );
+               }
+       }
 }
diff --git a/includes/GlobalRename/GlobalRenameUserLogger.php 
b/includes/GlobalRename/GlobalRenameUserLogger.php
index 3b52b44..9d59e20 100644
--- a/includes/GlobalRename/GlobalRenameUserLogger.php
+++ b/includes/GlobalRename/GlobalRenameUserLogger.php
@@ -38,6 +38,11 @@
                        '4::olduser' => $oldName,
                        '5::newuser' => $newName,
                ) );
+
+               $logEntry->setRelations( array(
+                       'oldname' => $oldName,
+               ) );
+
                $logid = $logEntry->insert();
                $logEntry->publish( $logid );
        }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I13c39874ff5f8690002658a34b9bcdf523ed0776
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to