r55997 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55996‎ | r55997 | r55998 >
Date:19:52, 7 September 2009
Author:happy-melon
Status:reverted
Tags:
Comment:
Follow-up to r55990, per comments:
* replace $wgOut->addHTML( wfMsgWikiHTML( )) with $wgOut->addWikiMsg
* Use Html::hidden instead of Xml::hidden
* use wfMsgExt instead of wfMsg, to avoid double parsing
* Use 'help-message' rather than 'help' => wfMsg()
Plus lots of whitespace fixes etc
Modified paths:
  • /trunk/phase3/includes/specials/SpecialCreateAccount.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialCreateAccount.php
@@ -52,6 +52,7 @@
5353 'id' => 'wpRealName',
5454 'tabindex' => '1',
5555 'size' => '20',
 56+ 'help-message' => 'prefs-help-realname',
5657 ),
5758 'Remember' => array(
5859 'type' => 'check',
@@ -70,7 +71,6 @@
7172 public function __construct(){
7273 parent::__construct( 'CreateAccount', 'createaccount' );
7374 $this->mLogin = new Login();
74 - $this->mFormFields['RealName']['help'] = wfMsg( 'prefs-help-realname' );
7575 }
7676
7777 public function execute( $par ){
@@ -82,25 +82,24 @@
8383 # Block signup here if in readonly. Keeps user from
8484 # going through the process (filling out data, etc)
8585 # and being informed later.
86 - if ( wfReadOnly() ) {
 86+ if( wfReadOnly() ) {
8787 $wgOut->readOnlyPage();
8888 return;
8989 }
9090 # Bail out straightaway on permissions errors
91 - if ( !$this->userCanExecute( $wgUser ) ) {
 91+ if( !$this->userCanExecute( $wgUser ) ) {
9292 $this->displayRestrictionError();
9393 return;
94 - } elseif ( $wgUser->isBlockedFromCreateAccount() ) {
 94+ } elseif( $wgUser->isBlockedFromCreateAccount() ) {
9595 $this->userBlockedMessage();
9696 return;
97 - } elseif ( count( $permErrors = $this->getTitle()->getUserPermissionsErrors( 'createaccount', $wgUser, true ) )>0 ) {
98 - var_dump('error');
 97+ } elseif( count( $permErrors = $this->getTitle()->getUserPermissionsErrors( 'createaccount', $wgUser, true ) )>0 ) {
9998 $wgOut->showPermissionsErrorPage( $permErrors, 'createaccount' );
10099 return;
101100 }
102101
103102 if( $this->mPosted ) {
104 - if ( $this->mCreateaccountMail ) {
 103+ if( $this->mCreateaccountMail ) {
105104 return $this->addNewAccountMailPassword();
106105 } else {
107106 return $this->addNewAccount();
@@ -251,7 +250,7 @@
252251 $wgOut->setPageTitle( wfMsgHtml( 'accountcreated' ) );
253252 $wgOut->setArticleRelated( false );
254253 $wgOut->setRobotPolicy( 'noindex,nofollow' );
255 - $wgOut->addHTML( wfMsgWikiHtml( 'accountcreatedtext', $user->getName() ) );
 254+ $wgOut->addWikiMsg( 'accountcreatedtext', $user->getName() );
256255 $wgOut->returnToMain( false, $self );
257256 wfRunHooks( 'AddNewAccount', array( $user ) );
258257 $user->addNewUserLogEntry();
@@ -282,7 +281,7 @@
283282 # cation server before they create an account (otherwise, they can
284283 # create a local account and login as any domain user). We only need
285284 # to check this for domains that aren't local.
286 - if( !in_array( $this->mDomain, array( 'local', '' ) )
 285+ if( !in_array( $this->mDomain, array( 'local', '' ) )
287286 && !$wgAuth->canCreateAccounts()
288287 && ( !$wgAuth->userExists( $this->mUsername )
289288 || !$wgAuth->authenticate( $this->mUsername, $this->mPassword )
@@ -293,7 +292,7 @@
294293 }
295294
296295 $ip = wfGetIP();
297 - if ( $wgEnableSorbs && !in_array( $ip, $wgProxyWhitelist ) &&
 296+ if( $wgEnableSorbs && !in_array( $ip, $wgProxyWhitelist ) &&
298297 $wgUser->inSorbsBlacklist( $ip ) )
299298 {
300299 $this->showMainForm( wfMsg( 'sorbs_create_account_reason' ) . ' (' . htmlspecialchars( $ip ) . ')' );
@@ -303,24 +302,24 @@
304303 # Now create a dummy user ($user) and check if it is valid
305304 $name = trim( $this->mUsername );
306305 $user = User::newFromName( $name, 'creatable' );
307 - if ( is_null( $user ) ) {
 306+ if( is_null( $user ) ) {
308307 $this->showMainForm( wfMsg( 'noname' ) );
309308 return false;
310309 }
311310
312 - if ( 0 != $user->idForName() ) {
 311+ if( 0 != $user->idForName() ) {
313312 $this->showMainForm( wfMsg( 'userexists' ) );
314313 return false;
315314 }
316315
317 - if ( 0 != strcmp( $this->mPassword, $this->mRetype ) ) {
 316+ if( 0 != strcmp( $this->mPassword, $this->mRetype ) ) {
318317 $this->showMainForm( wfMsg( 'badretype' ) );
319318 return false;
320319 }
321320
322321 # check for minimal password length
323322 $valid = $user->isValidPassword( $this->mPassword );
324 - if ( $valid !== true ) {
 323+ if( $valid !== true ) {
325324 if ( !$this->mCreateaccountMail ) {
326325 $this->showMainForm( wfMsgExt( $valid, array( 'parsemag' ), $wgMinimalPasswordLength ) );
327326 return false;
@@ -333,7 +332,7 @@
334333
335334 # if you need a confirmed email address to edit, then obviously you
336335 # need an email address.
337 - if ( $wgEmailConfirmToEdit && empty( $this->mEmail ) ) {
 336+ if( $wgEmailConfirmToEdit && empty( $this->mEmail ) ) {
338337 $this->showMainForm( wfMsg( 'noemailtitle' ) );
339338 return false;
340339 }
@@ -356,13 +355,13 @@
357356 return false;
358357 }
359358
360 - if ( $wgAccountCreationThrottle && $wgUser->isPingLimitable() ) {
 359+ if( $wgAccountCreationThrottle && $wgUser->isPingLimitable() ) {
361360 $key = wfMemcKey( 'acctcreate', 'ip', $ip );
362361 $value = $wgMemc->get( $key );
363362 if ( !$value ) {
364363 $wgMemc->set( $key, 0, 86400 );
365364 }
366 - if ( $value >= $wgAccountCreationThrottle ) {
 365+ if( $value >= $wgAccountCreationThrottle ) {
367366 $this->showMainForm( wfMsgExt( 'acct_creation_throttle_hit', array( 'parseinline' ), $wgAccountCreationThrottle ) );
368367 return false;
369368 }
@@ -418,8 +417,8 @@
419418 $blocker = User::whoIs( $wgUser->mBlock->mBy );
420419 $block_reason = $wgUser->mBlock->mReason;
421420
422 - if ( strval( $block_reason ) === '' ) {
423 - $block_reason = wfMsg( 'blockednoreason' );
 421+ if( strval( $block_reason ) === '' ) {
 422+ $block_reason = wfMsgExt( 'blockednoreason' );
424423 }
425424 $wgOut->addWikiMsg( 'cantcreateaccount-text', $ip, $block_reason, $blocker );
426425 $wgOut->returnToMain( false );
@@ -514,10 +513,10 @@
515514 unset( $this->mFormFields['Email'] );
516515 } else {
517516 if( $wgEmailConfirmToEdit ){
518 - $this->mFormFields['Email']['help'] = wfMsg( 'prefs-help-email-required' );
 517+ $this->mFormFields['Email']['help-message'] = 'prefs-help-email-required' ;
519518 $this->mFormFields['Email']['required'] = '';
520519 } else {
521 - $this->mFormFields['Email']['help'] = wfMsg( 'prefs-help-email' );
 520+ $this->mFormFields['Email']['help-message'] = 'prefs-help-email';
522521 }
523522 }
524523
@@ -551,8 +550,8 @@
552551 . $form->getBody()
553552 . $form->getButtons()
554553 . $buttons
555 - . Xml::hidden( 'returnto', $this->mReturnTo )
556 - . Xml::hidden( 'returntoquery', $this->mReturnToQuery )
 554+ . Html::hidden( 'returnto', $this->mReturnTo )
 555+ . Html::hidden( 'returntoquery', $this->mReturnToQuery )
557556 ;
558557
559558 $wgOut->setPageTitle( wfMsg( 'createaccount' ) );

Follow-up revisions

RevisionCommit summaryAuthorDate
r56058Revert broken rewrite of login forms:...brion18:40, 8 September 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r55990* Totally refactor includes/specials/SpecialUserlogin.php:...happy-melon19:00, 7 September 2009

Status & tagging log