r86011 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86010‎ | r86011 | r86012 >
Date:23:47, 13 April 2011
Author:nimishg
Status:reverted (Comments)
Tags:
Comment:
Created BeforeWelcomeCreation hook to be run before any welcome message gets displayed
Modified paths:
  • /trunk/phase3/includes/specials/SpecialUserlogin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialUserlogin.php
@@ -904,9 +904,14 @@
905905 global $wgUser;
906906 # Run any hooks; display injected HTML
907907 $injected_html = '';
 908+ $welcome_creation_msg = 'welcomecreation';
 909+
908910 wfRunHooks( 'UserLoginComplete', array( &$wgUser, &$injected_html ) );
909 -
910 - $this->displaySuccessfulLogin( 'welcomecreation', $injected_html );
 911+
 912+ //let any extensions change what message is shown
 913+ wfRunHooks( 'BeforeWelcomeCreation', array( &$welcome_creation_msg, &$injected_html ) );
 914+
 915+ $this->displaySuccessfulLogin( $welcome_creation_msg, $injected_html );
911916 }
912917
913918 /**
@@ -916,7 +921,10 @@
917922 global $wgOut, $wgUser;
918923
919924 $wgOut->setPageTitle( wfMsg( 'loginsuccesstitle' ) );
920 - $wgOut->addWikiMsg( $msgname, $wgUser->getName() );
 925+ if( $msgname ){
 926+ $wgOut->addWikiMsg( $msgname, $wgUser->getName() );
 927+ }
 928+
921929 $wgOut->addHTML( $injected_html );
922930
923931 if ( !empty( $this->mReturnTo ) ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r86960mft r86011nimishg18:07, 26 April 2011
r86972mft r86011, for real this timenimishg19:13, 26 April 2011

Comments

#Comment by Jack Phoenix (talk | contribs)   23:50, 13 April 2011

Some minor coding style issues here:

  • $welcome_creation_msg should be called $welcomeCreationMsg
  • I'd prefer a space after the double slashes: // let any extensions change what message is shown
  • space after ) and before { (if( $msgname ) {)

docs/hooks.txt should also be updated.

#Comment by Reedy (talk | contribs)   00:00, 14 April 2011

Also, an onwiki Manual page should be created for the hook

#Comment by Nimish Gautam (talk | contribs)   00:46, 15 April 2011

hooks.txt modified in r86103

This also exists now: http://www.mediawiki.org/wiki/Manual:Hooks/BeforeWelcomeCreation

I feel a little weird about using a CamelCase variable name when the rest of the function uses underscore_variables, so I didn't change that.

Status & tagging log