r82120 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82119‎ | r82120 | r82121 >
Date:17:59, 14 February 2011
Author:raymond
Status:reverted (Comments)
Tags:
Comment:
Add a link to Special:CentralAuth/username on the Special:Contributions tool links
Roughly tested locally only because I have no CentralAuth instance running.
Modified paths:
  • /trunk/extensions/CentralAuth/CentralAuth.i18n.php (modified) (history)
  • /trunk/extensions/CentralAuth/CentralAuth.php (modified) (history)
  • /trunk/extensions/CentralAuth/CentralAuthHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralAuth/CentralAuth.php
@@ -188,6 +188,9 @@
189189 $wgHooks['getUserPermissionsErrorsExpensive'][] = 'CentralAuthHooks::onGetUserPermissionsErrorsExpensive';
190190 $wgHooks['MakeGlobalVariablesScript'][] = 'CentralAuthHooks::onMakeGlobalVariablesScript';
191191
 192+// For Special:Contributions
 193+$wgHooks['ContributionsToolLinks'][] = 'CentralAuthHooks::onContributionsToolLinks';
 194+
192195 // For interaction with the Special:Renameuser extension
193196 $wgHooks['RenameUserWarning'][] = 'CentralAuthHooks::onRenameUserWarning';
194197 $wgHooks['RenameUserPreRename'][] = 'CentralAuthHooks::onRenameUserPreRename';
Index: trunk/extensions/CentralAuth/CentralAuthHooks.php
@@ -605,4 +605,23 @@
606606 $params['url'] = $wiki->getUrl( 'User:' . str_replace( ' ', '_', $user->getName() ) );
607607 return true;
608608 }
 609+
 610+ public static function onContributionsToolLinks( $id, $user, &$tools ) {
 611+ global $wgUser;
 612+
 613+ $globalUser = CentralAuthUser::getInstance( $user );
 614+ if ( $globalUser->exists() ) {
 615+ if ( $wgUser->isAllowed( 'centralauth-merge' ) ) { // Paranoia. Currently this right is assigned to '*'
 616+ $sk = $wgUser->getSkin();
 617+ $tools[] = $sk->linkKnown(
 618+ SpecialPage::getTitleFor( 'CentralAuth', $user->getText() ),
 619+ wfMsg( 'centralauth-link-on-contribs' ),
 620+ array( 'title' => wfMsgExt( 'centralauth-link-on-contribs-text', 'parseinline' ) )
 621+ );
 622+ }
 623+ } else {
 624+ $tools[] = wfMsg( 'centralauth-link-on-contribs-no' );
 625+ }
 626+ return true;
 627+ }
609628 }
Index: trunk/extensions/CentralAuth/CentralAuth.i18n.php
@@ -238,6 +238,11 @@
239239 Renaming it will cause the local user to be detached from the global one.",
240240 'centralauth-renameuser-reserved' => "User $2 is reserved for a global account.",
241241
 242+ // Interaction with Special:Contributions
 243+ 'centralauth-link-on-contribs' => 'global account status',
 244+ 'centralauth-link-on-contribs-text' => 'Status of the global account for this user',
 245+ 'centralauth-link-on-contribs-no' => 'no global account',
 246+
242247 // Other messages
243248 'centralauth-invalid-wiki' => 'No such wiki database: $1',
244249 'centralauth-account-exists' => 'Cannot create account: the requested username is already taken in the unified login system.',

Follow-up revisions

RevisionCommit summaryAuthorDate
r85997Revert r82120: untested code causes fatal error on Special:Contributions when...brion22:57, 13 April 2011
r85999Use type hinting on CentralAuthUser::getInstance()'s user parameter. Makes it...brion22:58, 13 April 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   22:53, 13 April 2011

This causes a fatal error because it tries to pass a Title object (the second parameter of ContibutionsToolLinks, which is the title of the user page) to a function expecting a User object. It then dies because the Title object doesn't have a getName() parameter.

Status & tagging log