r58025 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58024‎ | r58025 | r58026 >
Date:16:54, 22 October 2009
Author:aude
Status:reverted (Comments)
Tags:
Comment:
more specific error message, using WikiError, if user trys to create account with hash character
Modified paths:
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUserlogin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -354,8 +354,10 @@
355355 $validate = 'valid';
356356 }
357357 $name = self::getCanonicalName( $name, $validate );
358 - if ( $name === false ) {
359 - return null;
 358+ if ( WikiError::isError( $name ) ) {
 359+ return $name;
 360+ } elseif ( $name === false ) {
 361+ return false;
360362 } else {
361363 # Create unloaded user object
362364 $u = new User;
@@ -693,7 +695,7 @@
694696 # with title normalisation, but then it's too late to
695697 # check elsewhere
696698 if( strpos( $name, '#' ) !== false )
697 - return false;
 699+ return new WikiError( 'usernamehasherror' );
698700
699701 # Clean up name according to title rules
700702 $t = ( $validate === 'valid' ) ?
Index: trunk/phase3/includes/specials/SpecialUserlogin.php
@@ -267,6 +267,11 @@
268268 # Now create a dummy user ($u) and check if it is valid
269269 $name = trim( $this->mName );
270270 $u = User::newFromName( $name, 'creatable' );
 271+ if ( WikiError::isError( $u ) ) {
 272+ $this->mainLoginForm( wfMsg( $u->getMessage() ) );
 273+ return false;
 274+ }
 275+
271276 if ( is_null( $u ) ) {
272277 $this->mainLoginForm( wfMsg( 'noname' ) );
273278 return false;

Follow-up revisions

RevisionCommit summaryAuthorDate
r61916Revert r58025 (User::newFromName() returns WikiError under certain circumstan...tstarling07:39, 3 February 2010

Comments

#Comment by Tim Starling (talk | contribs)   06:04, 17 December 2009

Lacks a corresponding documentation update and breaks about 6 core callers and an extension. I believe most of those callers are now fixed, but the change is still incomplete, returning an informative WikiError in this one pet case and false in another ~5 cases, forcing callers to check for both WikiError::isError() and false. Suggest a revert and a rethink. Splitting the interface into a new function that returns an informative Status, and a backwards compatible function that returns a name, would be a reasonable approach.

Status & tagging log