jenkins-bot has submitted this change and it was merged. Change subject: Log promote to global renames in the global rename log ......................................................................
Log promote to global renames in the global rename log Bug: T93235 Change-Id: I472842bdca2c2490f2a1376819d8f422b63991ea (cherry picked from commit e4708811a9584665fe0a252fbf7de425f9f5d282) --- M CentralAuth.php M i18n/en.json M i18n/qqq.json M includes/GlobalRename/GlobalRenameLogFormatter.php M includes/GlobalRename/GlobalRenameUserLogger.php M includes/specials/SpecialGlobalRenameQueue.php 6 files changed, 72 insertions(+), 3 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/CentralAuth.php b/CentralAuth.php index a5e9b1e..3518eec 100644 --- a/CentralAuth.php +++ b/CentralAuth.php @@ -477,6 +477,7 @@ $wgLogActions['gblrights/groupprms3'] = 'centralauth-rightslog-entry-groupperms3'; $wgLogActionsHandlers['gblrights/grouprename'] = 'efHandleGrouprenameLogEntry'; $wgLogActionsHandlers['gblrename/rename'] = 'GlobalRenameLogFormatter'; +$wgLogActionsHandlers['gblrename/promote'] = 'GlobalRenameLogFormatter'; $wgLogActionsHandlers['gblrename/merge'] = 'GlobalUserMergeLogFormatter'; foreach ( array( 'newset', 'setrename', 'setnewtype', 'setchange', 'deleteset' ) as $type ) { diff --git a/i18n/en.json b/i18n/en.json index 54af761..d18b772 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -396,6 +396,7 @@ "log-name-gblrename": "Global rename log", "log-description-gblrename": "This log tracks the global renaming of users.", "logentry-gblrename-rename" : "$1 globally {{GENDER:$2|renamed}} $4 to $5", + "logentry-gblrename-promote" : "$1 globally {{GENDER:$2|renamed}} $4 to $5", "globalusermerge": "Merge global user", "globalusermerge-legend": "Merge global user", "centralauth-usermerge-form-newuser": "Final username", diff --git a/i18n/qqq.json b/i18n/qqq.json index ffc6e86..a316ac7 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -408,7 +408,8 @@ "centralauth-rename-confirm": "Confirmation text asking whether the global account should really be renamed.\n\nSee also:\n* {{msg-mw|Centralauth-usermerge-confirm}}", "log-name-gblrename": "Log page title", "log-description-gblrename": "Log page description", - "logentry-gblrename-rename": "{{Logentry}}\nAdditional parameters:\n* $4 - old username\n* $5 - new username\nSee also:\n* {{msg-mw|Logentry-gblrename-merge}}", + "logentry-gblrename-rename": "{{Logentry}}\nAdditional parameters:\n* $4 - old username\n* $5 - new username\nSee also:\n* {{msg-mw|Logentry-gblrename-merge}}\n* {{mw-msg|logentry-gblrename-promote}}", + "logentry-gblrename-promote": "{{Logentry}}\nAdditional parameters:\n* $4 - old username\n* $5 - new username\nSee also:\n* {{msg-mw|Logentry-gblrename-merge}}\n* {{mw-msg|logentry-gblrename-rename}}", "globalusermerge": "Name of special page", "globalusermerge-legend": "Legend of fieldset surrounding the form", "centralauth-usermerge-form-newuser": "Label for form field", diff --git a/includes/GlobalRename/GlobalRenameLogFormatter.php b/includes/GlobalRename/GlobalRenameLogFormatter.php index d93771d..bf14164 100644 --- a/includes/GlobalRename/GlobalRenameLogFormatter.php +++ b/includes/GlobalRename/GlobalRenameLogFormatter.php @@ -1,14 +1,20 @@ <?php /** - * Make the gblrename/rename log entry look pretty + * Handles the following log types: + * - gblrename/rename + * - gblrename/promote */ class GlobalRenameLogFormatter extends LogFormatter { protected function getMessageParameters() { parent::getMessageParameters(); $params = $this->extractParameters(); - $this->parsedParameters[3] = $this->getCentralAuthLink( $params[3] ); + if ( $this->entry->getSubtype() === 'promote' ) { + $this->parsedParameters[3] = $this->getLocalWikiLink( $params[3], $params[5] ); + } else { // rename + $this->parsedParameters[3] = $this->getCentralAuthLink( $params[3] ); + } $this->parsedParameters[4] = $this->getCentralAuthLink( $params[4] ); ksort( $this->parsedParameters ); @@ -27,4 +33,13 @@ return Message::rawParam( Linker::link( $title, htmlspecialchars( $name ) ) ); } + + protected function getLocalWikiLink( $name, $wiki ) { + $text = "User:$name@$wiki"; + if ( $this->plaintext ) { + return "[[$text]]"; + } + + return Message::rawParam( WikiMap::foreignUserLink( $wiki, $name, $text ) ); + } } diff --git a/includes/GlobalRename/GlobalRenameUserLogger.php b/includes/GlobalRename/GlobalRenameUserLogger.php index 9c854d7..a1d1a3d 100644 --- a/includes/GlobalRename/GlobalRenameUserLogger.php +++ b/includes/GlobalRename/GlobalRenameUserLogger.php @@ -46,4 +46,35 @@ $logid = $logEntry->insert(); $logEntry->publish( $logid ); } + + /** + * Log the promotion of a local unattached to a global + * + * @param string $oldName + * @param string $wiki + * @param string $newName + * @param string $reason + */ + public function logPromotion( $oldName, $wiki, $newName, $reason ) { + $logEntry = new ManualLogEntry( 'gblrename', 'promote' ); + $logEntry->setPerformer( $this->performingUser ); + + $logEntry->setTarget( + Title::makeTitleSafe( NS_SPECIAL, 'CentralAuth/' . $newName ) + ); + + $logEntry->setComment( $reason ); + $logEntry->setParameters( array( + '4::olduser' => $oldName, + '5::newuser' => $newName, + '6::oldwiki' => $wiki, + ) ); + + $logEntry->setRelations( array( + 'oldname' => $oldName, + ) ); + + $logid = $logEntry->insert(); + $logEntry->publish( $logid ); + } } diff --git a/includes/specials/SpecialGlobalRenameQueue.php b/includes/specials/SpecialGlobalRenameQueue.php index 9db7fda..7461cc9 100644 --- a/includes/specials/SpecialGlobalRenameQueue.php +++ b/includes/specials/SpecialGlobalRenameQueue.php @@ -415,6 +415,13 @@ ) ); JobQueueGroup::singleton( $request->getWiki() )->push( $job ); + // Now log it + $this->logPromotionRename( + $oldUser->getName(), + $request->getWiki(), + $newUser->getName(), + $data['reason'] + ); $status = Status::newGood(); } } @@ -472,6 +479,19 @@ } /** + * Log a promotion to global rename in the global rename log + * + * @param string $oldName + * @param string $wiki + * @param string $newName + * @param string $reason + */ + protected function logPromotionRename( $oldName, $wiki, $newName, $reason ) { + $logger = new GlobalRenameUserLogger( $this->getUser() ); + $logger->logPromotion( $oldName, $wiki, $newName, $reason ); + } + + /** * Get a MailAddress for a user on a remote wiki * * @param string $wiki -- To view, visit https://gerrit.wikimedia.org/r/202739 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I472842bdca2c2490f2a1376819d8f422b63991ea Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CentralAuth Gerrit-Branch: wmf/1.25wmf24 Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits